Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Validation

Status
Not open for further replies.
Aug 13, 2001
14
DK





View Message Thread (1 reply)

Form validation
From: Rajkumar
Date Posted: 4/24/2002 3:57:00 AM

In a form I have many dates and would like to validate all of them when the
form is submitted.

The date validation function is passed three parameters: Date value, form
number, field number.

It works fine for a form number 0, field number 3 using the following:

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Save&quot; class=&quot;Button&quot;
ONCLICK=&quot;return validate(formname.datefield.value,0,3);&quot;>

How can I make it work for all the date fields.

One way is that I make one function per Form and then call date validation
function for each date field.

Is there a better way?

Thanks,
Raj



 
make one big function that does it all :

function checkForm()
{
if (!validate(formname.datefield.value,0,3))return false
if (!validate(formname.datefield2.value,0,3))return false
// same with all other fields

return true;// if no return false is done this line is executed and says the submit is fine.
}

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Save&quot; class=&quot;Button&quot;
ONCLICK=&quot;return checkForm()&quot;>

I hope this helps. Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top