Form validation with jQuery and php
<p>I have a form which I'm validating using jQuery and php. So basically if the php echoes "input must be filled"  the jQuery should put a red border around that input, but the thing works only after submitting the form two times.<br>
I explain: if I submit with input unfilled the php file echoes "input must be filled", but only if I press again the submit button - the input goes red.</p>

<pre><code>$("form#maj_email").submit(function(){
var _data = $(this).serialize()
$.ajax({
        type: 'POST',
        url: 'validation_profil.php?var=maj_email',
        beforeSend: function(){
            $("div#ajax_icon_maj_email").css({background:"url('http://localhost/www3/images/ajax_loader.gif')"})
            $("div#error_maj_email").hide()
             if( $("div#error_maj_email").text()=="Email syntaxe incorrecte"){
               $("form#maj_email input:[name=email]").css({border:"1px solid red"})
             }

        },
        data:_data,
        cache: false,
        success: function(html){
            $('div#error_maj_email').html(html)
            $("div#ajax_icon_maj_email").css({background:"url('none')"})
            $("div#error_maj_email").fadeIn()
        }
     })
})
</code></pre>
