jquery validation with ajax call

前端 未结 4 1279
闹比i
闹比i 2020-12-06 00:58

I am using the jquery validation and i need to validate an email.

I use

    $(\"#myForm\").validate({
        rules: 
            email: {
                   


        
4条回答
  •  攒了一身酷
    2020-12-06 01:08

    Whats your server language? PHP or ASP?

    This is the jQuery part:

    $.ajax({
        type: "POST",
        url: "YourWebserviceOrWhatEver",
        data: "{'Email':'your@ema.il'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
          if(msg.EmailExists){
            //Email exists
            alert("This email already exists. Please select other");
          }
          else {
           //Email doesn't exist yet
           doSomething();
          }
        }
    });
    

提交回复
热议问题