i tried validate text field data not include word abc in example. code:
function valinput() { $.validator.addmethod("notequalto",function (value, element, param) { return this.optional(element) || value != param ; }, "name must not contain abc"); $("#form1").validate({ rules: { <%=txtname.uniqueid%>: { required: true, notequalto: "abc" } }, //rules messages: { <%=txtname.uniqueid%>: { required: "name required field.", notequal: "name must not contain word abc" } }, errorplacement: function (error, element) { alert(error.text()); } }); } the field validate if name abc; want validate if abc in middle or @ end or place in name, how do that? how use indexof (in jquery) situation ? appreciated.
try indexof method this.
var word = "name must not contain word abc"; if(word.indexof("abc")>=0) //do hope helps you.
Comments
Post a Comment