Validate Form with PHP AND Javascriipt?

Posted by J M 4 on Stack Overflow See other posts from Stack Overflow or by J M 4
Published on 2010-05-10T21:36:39Z Indexed on 2010/05/10 23:04 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

Is it possible to validate a form with PHP AND Javascript? I am currently able to do both using my existing form but only on an individual basis.

My overall goal is this:

  1. Validate form using javascript client side and present any errors to the user immediately
  2. If javascript validation passes, a flag is created and then the PHP script can begin.

When doing my javascript validation, i use the following code within the form tag:

<form id="Enroll_Form"  action="review.php" method="post" name="Enroll_Form" onsubmit="return Enroll_Form_Validator(this)" language="javascript">

if I want to process the PHP validation, I am forced to rename the action to the PHP_SELF file (or simply the same file name i'm using) and remove the 'onsubmit' function.

Any ideas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about php