Created
September 17, 2018 13:21
-
-
Save Chandrakanth339/52fe02b6820d788dbf0e0cdb20d8c59b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(()=>{ | |
$.validator.addMethod('nameLen',(value, element)=>{ | |
return /([^a]{2}$)/g.test(value); | |
},"Your Email is not in proper format.... please correct the same......"); | |
$("#form1").validate({ | |
rules:{ | |
inpt:{ | |
required: true, | |
nameLen: true | |
}, | |
inpt2:{ | |
required: true | |
} | |
}, | |
messages:{ | |
inpt:{ | |
required: "This field is mandatory" | |
}, | |
inpt2:{ | |
required: "This field is mandatory" | |
} | |
}, | |
errorElement: "span", | |
errorPlacement: (error, element)=>{ | |
if(element.attr("name") =="inpt"){ | |
$(".err").html(error); | |
} | |
if(element.attr("name") =="inpt2"){ | |
$(".err2").html(error); | |
} | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment