Click to See Complete Forum and Search --> : CheckForm(this)


monalisa
05-07-2003, 11:52 AM
I'm using a check form function in javascript to check my form upon completion. The form tag is as follows:
<form enctype="multipart/form-data" name="frmUpload" method="post" action="upload.asp" onSubmit="return checkForm(this);">

This should use the following function to make sure that everything within the form is filled out correctly.


function checkForm(frm)
{
if(frm.filLO.value.length == 0)
{
alert("Please choose the file to upload.");
frm.filLO.focus();
return false;
}
if(frm.txtB1FirstName.value.length == 0)
{
alert("Please enter the borrower's first name");
frm.txtB1FirstName.focus();
return false;
}
if(frm.txtB1LastName.value.length == 0)
{
alert("Please enter the borrower's last name");
frm.txtB1LastName.focus();
return false;
}
if(frm.txtB1CreditScore.value.length == 0)
{
alert("Please enter the borrower's middle credit score");
frm.txtB1CreditScore.focus();
return false;
}
if(frm.selState.value.length == 0)
{
alert("Please select the property state.");
frm.selState.focus();
return false;
}
if(frm.selLoanPurpose.value.length == 0)
{
alert("Please select the loan purpose");
frm.selLoanPurpose.focus();
return false;
}
return true;
}

The problem is, after the form is submitted, the checkform function is never ran!!! I'm not sure why because it works for a similar form that also uses a checkForm function. Has anyone else had a similar situation and know how to fix this??

Charles
05-07-2003, 11:56 AM
If you are using XHTML then it might be because there is no onSubmit handler; it's onsubmit. If that's not the problem then give us a URL, please.