Validation problem...

S

Shan

I am using a javascript function to validate my enquiry form.
When i tested the script, it alerts the error but after alerting
error, the form was submitted.
i didnt find any error in Error console(Firefox)

here is code that i am using ....
html part


<form name="frmName" method="POST" action="enquiry.php"
onSubmit="javascript:return validate_enquiry()">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr class="formtext">
<td width="20%">First Name</td>
<td>
<input type="text" name="varFname" value="<?=(!
empty($val_ary['varFname'])?$val_ary['varFname']:'')?>"
class="inputbox">
</td>
</tr>
<tr class="formtext">
<td>Last Name</td>
<td>
<input type="text" name="varLname" value="<?=(!
empty($val_ary['varLname'])?$val_ary['varLname']:'')?>"
class="inputbox">
</td>
</tr>
</table>
</form>

script part

function validate_enquiry(){

var_fname = document.frmName.varFname.value;
var_fname = var_fname.replace(/^\s+|\s+$/g, '') ;
if(var_fname==''){
alert('Empty/Invalid input for First Name');
document.getElementById('varFname').focus();
return false;
}

var_lname = document.frmName.varLname.value;
var_lname =var_lname.replace(/^\s+|\s+$/g, '') ;
if (var_lname==''){
alert('Empty/Invalid input for Last Name');
document.getElementById('varLname').focus();
return false;
}
return true;
}


can any one suggest the wrong thing with my code...
i am tesing in Firefox 2....

Advance thanks for any help...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,798
Messages
2,569,651
Members
45,385
Latest member
ZapGuardianReviews

Latest Threads

Top