2 buttons in ASPX page

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
 
P

Paul Johnson

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>
 
P

Peter Blum

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
 

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,787
Messages
2,569,630
Members
45,335
Latest member
Tommiesal

Latest Threads

Top