silverlight
New Member
I have written the following code but the form tries to post as if the javascript is not being found?the code is within the \[code\]<head>\[/code\] of the document:\[code\]<script language="JavaScript" type="text/javascript"> $('.entrysend').click(function(e){ e.preventDefault(); var error = false; var name = $('#name').val(); var address = $('#address').val(); var phone = $('#phone').val(); var email = $('#email').val(); if(name.length == 0){ var error = true; alert("Please complete all fields"); } if(address.length == 0){ var error = true; alert("Please complete all fields"); } if(phone.length == 0){ var error = true; alert("Please complete all fields"); } if(email.length == 0){ var error = true; alert("Please complete all fields"); } if(error == false){ $.post("compthanks.asp", $(".entry").serialize(), function(result){ if($.trim(result) == 'sent'){ $('.entrysend').remove(); alert("Thanks for entering!"); } }</script>\[/code\]HTML:\[code\]<form class="entry" action="compthanks.asp" method="post" class="floatClear" name="entryForm"> <br class="floatClear" /> <div class="formwrapper"> <input name="name" id="name" type="text" placeholder="FullName" /> </div> <div class="formwrapper"> <textarea name="address" id="address" placeholder="Address" cols="20" rows="10"></textarea> </div> <div class="formwrapper"> <input name="phone" id="phone" type="text" placeholder="ContactNumber" /> </div> <div class="formwrapper"> <input name="email" id="email" type="text" placeholder="Email" /> </div> <div class="formwrapper floatClear"> <input name="submit" type="submit" value="http://stackoverflow.com/questions/15830568/Send Entry" class="entrysend" /> </div></form>\[/code\]Can anyone point out the reason why the form still submits as opposed to the javascript kicking in?