JQuery and PHP validation problem?

Posted by DuH on Stack Overflow See other posts from Stack Overflow or by DuH
Published on 2010-03-24T06:57:08Z Indexed on 2010/03/24 7:03 UTC
Read the original article Hit count: 228

Filed under:
|

I want to do the validation on my PHP side and then have my JQuery code display your changes have been saved when the submit button is clicked but the JQuery code states that the changes have been saved even when the validation fails.

How can i fix this so that PHP can do the validation and then JQuery can do its thing when PHP has finished its validation?

Here is my Jquery code.

$(function() {
    $('#changes-saved').hide();
    $('.save-button').click(function() {
        $.post($('#contact-form').attr('action'), $('#contact-form').serialize(), function(html) {
            $('div.contact-info-form').html(html);
            $('#changes-saved').hide();
            $('#changes-saved').html('Your changes have been saved!').fadeIn(4000).show();
        });

        $('a').click(function () {
            $('#changes-saved').empty();
            $('#changes-saved').hide();
        });

        return false; // prevent normal submit
    });
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about php