Form validation q 
Author Message
 Form validation q

I have:
-a form which posts to a php page
-a javascript validation function which returns true or false depending on
if the form is valid

I have read to do the following to combine the two:
<form name="myForm" method="post" action="trustEval.php" onSubmit="return
verify()">
...
</form>

..So, when testing, the validation script runs on the submit request and
finds errors if they exist, but the post completes anyway -
How can I set it so the post will not occur unless the verify() returns
true?

thanks in advance
-matt

--
///////////////////////////////
m roberts

http://www.*-*-*.com/



Sat, 06 Aug 2005 06:10:13 GMT  
 Form validation q



Quote:
> I have:
> -a form which posts to a php page
> -a javascript validation function which returns true or false depending on
> if the form is valid

> I have read to do the following to combine the two:
> <form name="myForm" method="post" action="trustEval.php" onSubmit="return
> verify()">
> ...
> </form>

> ..So, when testing, the validation script runs on the submit request and
> finds errors if they exist, but the post completes anyway -
> How can I set it so the post will not occur unless the verify() returns
> true?

Two things can go wrong here: The verify() function does not return false on
failure or it contains an error. Try with OnSubmit="verify();return false"
and check for errors. Post the verify() function when this doesn't help you.

JW



Sat, 06 Aug 2005 06:19:11 GMT  
 Form validation q

Quote:
> Thus its your
> javascript not returning false when you expect it to.

That was it - thanks for the clarification on how it works...

-,m



Sat, 06 Aug 2005 07:30:31 GMT  
 Form validation q

Quote:

> I have:
> -a form which posts to a php page
> -a javascript validation function which returns true or false depending on
> if the form is valid

> <form name="myForm" method="post" action="trustEval.php" onSubmit="return
> verify()">
> ...
> </form>

I hope you understand that you will have to revalidate all the data in PHP
and that the data coming from this form can't be trusted (I'm saying this
because your action is "trustEval.php".

Andr N?ss



Sat, 06 Aug 2005 15:17:38 GMT  
 Form validation q
Hello,


Quote:
> I have:
> -a form which posts to a php page
> -a javascript validation function which returns true or false depending on
> if the form is valid

> I have read to do the following to combine the two:
> <form name="myForm" method="post" action="trustEval.php" onSubmit="return
> verify()">
> ...
> </form>

> ..So, when testing, the validation script runs on the submit request and
> finds errors if they exist, but the post completes anyway -
> How can I set it so the post will not occur unless the verify() returns
> true?

You may want to try this PHP class that does exactly that for you: it
generates HTML for the form with the necessary Javascript code to
validate on the client side and the class itself can validate the form
on the server side:

http://www.phpclasses.org/formsgeneration

--

Regards,
Manuel Lemos



Sat, 06 Aug 2005 15:23:44 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. form validation

2. Form Validation

3. Form validation and page navigation

4. Form validation problem: URGENT

5. Field Validation in a Form

6. Validation of FORM fields

7. HTML Form data validation with Object REXX (Windows)

8. Date validation of input from HTML form

9. newbie with a php validation form mail script problem

10. clientside validation of checkboxes from PHP form

11. J Form Editor resizing a form?

12. J Form Editor resizing a form

 

 
Powered by phpBB® Forum Software