Skip to content Skip to sidebar Skip to footer

Jquery Validation - Validate Email Using Ajax Call

I have an invitation form that should only accept emails handled by GMail. I'm trying to plug in asynchronous validation, but not sure what should be returned from the server and w

Solution 1:

problem solved.

Javascript code:

$('#invite').validate({rules: {
        email: {
            required:true,
            email:true,
            remote: {
                url:'/admin/isgmail/',
                type:'POST',
                dataType:'json',
                data: {
                    email:function() {
                        return$('#email').val();
                    }
                }
            }
        }
    },messages: {
        email:"GMail email is required."
    },onkeyup:false});

invite.php should return string "true" if validation is successful, string "false" if there was an error OR JSON-encoded string describing the error: echo json_encode('This is not a Google account');.

Post a Comment for "Jquery Validation - Validate Email Using Ajax Call"