2 buttons in ASPX page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a aspx form with 2 submit buttons.

For the first button, it submits 2 text box data and no need to do
javascript validation.

For the second button, it submits 5 text box data and has to do javascript
validation to check email, phone, etc.

The form tag has onsubmit="javascript:return CheckInput();"

Since it is not possible to include 2 form tags in one aspx form, the js
validation performs checking when I input data and press the first button.
However, js validation is done only when the 2nd button is pressed.

So, how can I fix that problem or I have to use 2 separate forms?

Thanks
 
Can't you use a button instead of a submit in the case one that needs to
validate, then have an onlcick="CheckInputAndSubmit"

then in your CheckInputAndSubmit function have a form1.submit(); at the
end of the function if the form is valid.

<Form ID="Form1" runat="server">
<Input type="Button" onclick="CheckInputAndSubmit">
</Form>
<script .... . >
CheckInputAndSubmit()
{
...
......

Form1.submit();
}
</script>
 
It doesn't sound like you are using the ASP.NET Validation web controls. If
you did, this would be easy.
Add the necessary validators, using the CustomValidator to handle cases you
cannot.
Set the button's CausesValidation property to false when it should not
validate.

If you investigated the ASP.NET Validation web controls and found it lacking
something, "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) is a replacement that addresses
most of the issues with Microsoft's validators including client-side
validation on many more browsers than just IE and IE/Mac.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top