Validate with multiple submit buttons

  • Thread starter Thread starter pete0085
  • Start date Start date
P

pete0085

I ran into a problem when preforming a validation in a form. The form
actually has two submit buttons. The first submit button automatically fills
in user information (called autofill), but the input type needs to be
"submit" The second submit button should be doing the validation. How can I
get around this?

Here is the script that does the validation:

function ValidateForm(){
var dt=document.frmSample.date1;
var dt1=document.frmSample.date2;
if (isDate(dt.value)==false) {
dt.focus();
return false;
}
if (isDate(dt1.value)==false){
dt1.focus();
return false;
}
return true;
}

The first "submit" button should not validate:
<input type="submit" value="Autofill" name="obbtn_ks108">

This second submit button needs to do the validation:
<input type="submit" value="Submit" name="obbtn_yes">
 
Which button actually submits the completed form? The other should be a
simple button with an onclick event to run whatever has to be run. Only one
submit button is allowed for a form.

Example:

<input name="Button1" type="button" value="button" onclick="whatEver()" />

But then, why have two buttons? a single submit button can validate the
form and then submit it.
--
Ron Symonds
Microsoft MVP (Expression)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
Back
Top