javascript - jQuery Validation - validate email using AJAX call -
I have an invitation form, which should only accept email handled by Gmail. I am trying to plug in asynchronous verification, but it is not certain what should be returned to the server and whether the javascript handler should be used.
- I do not have a "Gmail address"
- I want to get the message "no Gmail address" from the backend.
My attempt (not very good):
Validate $ ('# invite') ({SubmitHandler: function (form, e) {$ .ajax ({type: 'POST', url: $ (form)) .attr ('Action'), data: {email: $ (form) .find ('# email'). Val ()}, Success: Function () {debugger;}, error: function () {warning ('failed');}}); Return Return;}, Invalid Handler: Function (Event, Vedicator) {Debugger;}, Rule: {Email: {Required: True, Email: True, Remote: {url: "/invite.php" Type: "Post", async : True, data: submitted emails}}}});
Thanks!
The problem is resolved.
Javascript code:
$ ('# invited'). Validate ({Rule: {email: {required: true, email: true, remote: {url: '/ admin / isgmail /', type: 'post', datatype: 'jason', data: {email: function ) {Return $ ('# email'). Val ();}}}}, Message: {email: "GMail email is required."}, Onkeyup: false}); The string "true" should be returned
invite.php if the verification is successful, the string "false" If any error or JSON-encoded string describes the error:
echo json_encode ('this is not a Google account'); .
Comments
Post a Comment