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.

  1. I do not have a "Gmail address"
  2. 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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -