Return the fields that do not pass validation in PHP to jQuery
<p>I'm using jQuery with PHP for form validation. I want to return the fields that do not validate so i can highlight them using javascript</p>

<p>this is my attempt using PHP(validate.php):</p>

<pre><code>&lt;?php
...
$a_invalidInput = array();

$from = $_POST['from'];
$to = $_POST['to'];
$email_to = $_POST['email_to'];

if( empty($from) ){
   $a_invalidInput[] = 'from';
}

if( empty($to) ){
   $a_invalidInput[] = 'to';
}

//validate the email_to address
if( empty($email_to) ){
   $a_invalidInput[] = 'email_to';
} else{

   //do more validation for email
}
...
?&gt;
</code></pre>

<p>This is my jquery code:</p>

<pre><code>...

var data = "from="+ from + "&amp;to=" + to + "&amp;email_to=" + email_to; 

$.ajax({
   url: "includes/validate.php",
   type: "POST",
   data: data,
   success: function(){

      //highlight fields that do not pass validation

   }
});

...
</code></pre>

<p>I'm not sure if i'm on the right path or not AND how to return the input fields that do not pass validation so i can add a class to highlight the fields that do not pass validation.</p>

<p>I could do this using javascript but i prefer using a php file for validation</p>

<p>Thanks
Marco</p>
