Skip to content

Instantly share code, notes, and snippets.

@Chandrakanth339
Created September 17, 2018 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chandrakanth339/52fe02b6820d788dbf0e0cdb20d8c59b to your computer and use it in GitHub Desktop.
Save Chandrakanth339/52fe02b6820d788dbf0e0cdb20d8c59b to your computer and use it in GitHub Desktop.
$(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