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!

calling asp from xhtml form after validation by javascript

Status
Not open for further replies.

smhaig

Programmer
Jul 19, 2004
7
US
I have a contact form on a web site with a submit button. The fields are validated by a js file that returns true if no errors or false if errors to the form. If no errors, I need to call an asp file which will just create and send an email that contains the info from the contact form. Otherwise, the asp file should not be called.

What happens is that the asp file is called whether there are errors or not on the form and the email is sent. I know that the js validation is working correctly and so is the asp. The problem is I need a conditional in the xhtml form. I tried onsubmit but that did not seem to do anything. I can post a few lines of code if the problem is not evident. I have seen many samples but nothing regarding this particular situation.

Thanks
 
To stop submission you need to return a false value to the event. You need to take the value from your function and return it again.

This can either be done in the onClick event of the submit button, or the onSubmit event of the form.

Code:
<form action"..." ... onsubmit="[red]return[/red] functionName();">

or

<input type="submit" ... onclick="[red]return[/red] functionname();">

Make sure your function is set up to return false if there is an error with the validation.

For further Javascript questions I suggest posting in the forum216

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top