PDA

View Full Version : Form Validation and Document Passing


ZiaJet
10-23-2002, 12:28 AM
Hi,
I'd like to know that if you have a form coded in the following manner:

<form name="CheckOut" action="confirmorder.html" method="Post">

Can this code be changed to something like: onSubmit="validatePost()", so it calls the function "validatePost(), so the form items can be checked for user input and if the validation passes the form is then sent to a target file for posting?

Cheers,
Jean-Raul


:rolleyes:

beetle
10-23-2002, 01:07 AM
You have to get a return value from the function being called by onSubmit

<form name="CheckOut" action="confirmorder.html" method="Post" onSubmit="return validatePost();">

If you are looking for some javascript form validation, I'd be pleased you you checked out my fValidate (http://www.peterbailey.net/fValidate)

Cheers :D

whammy
10-23-2002, 01:39 AM
beetle is absolutely correct about getting a boolean value (true or false) returned from the function with:

onsubmit="return validatePost()"

That's one thing that's rarely mentioned in forms/javascript tutorials except here (http://hotwired.lycos.com/webmonkey/programming/javascript/tutorials/tutorial1.html)...

:D

I haven't had a chance to check out beetle's fValidate API, but I'm sure it's pretty good judging by the answers I've seen him post. :)

ZiaJet
10-23-2002, 04:47 PM
I'd like to extend a hearty thank you to beetle and whammy for their response to my question. I really do appreciate their willingness to help and share knowledge.

Salute to you both,
Jean-Raul@zia