The problem what i am facing is when i click on the submit button in the form its not validating but directly posting to the php script while when i click on text boxes its validating perfectly i would need to validate the form before submission
Javascript Code
<script type="text/javascript">
//Begin of Ready document
$(document).ready(function () {
$("#fname").blur(function(){
if($("#fname").val() == "" ){
$("#fname").focus();
$("#fvalid").html("First Name Cannot be Blank");
return false;
}else{
$("#fvalid").html("");
return true;
}
});
$("#lname").blur(function(){
if($("#lname").val() == "" ){
$("#lname").focus();
$("#lvalid").html("Last Name Cannot be Blank");
return false;
}else{
$("#lvalid").html("");
return true;
}
});
</script>
HTML Code
<table class="content" cellspacing="0" cellpadding="0" align="center" style="padding-top:20px;">
<tr>
<td class="contentfont">First Name<span class="sup">*</span></td>
<td class="contentfont">:</td>
<td><input type="textbox" name="fname" class="textbox" id="fname"></td>
</tr>
<tr>
<td colspan="3"><span id="fvalid" class="failed"></span></td>
</tr>
<tr>
<td class="contentfont">Last Name<span class="sup">*</span></td>
<td class="contentfont">:</td>
<td><input type="textbox" class="textbox" name="lname" id="lname"></td>
</tr>
<tr>
<td colspan="3"><span id="lvalid" class="failed"></span></td>
</tr>
<tr>
<td align="center" colspan="3"><input type="submit" name="submit" class="register" value="Register Now" id="submit"></td>
</tr>
<tr>
<td align="center" colspan="3"><input type="submit" name="submit" class="register" value="Register Now" id="submit"></td>
</tr>
</table>
Can some one please help fix this
Aucun commentaire:
Enregistrer un commentaire