JQuery Validation for Data List

Posted on Leave a commentPosted in JQuery

JQuery Method by which we can validate the value is chosen from data list or not .   jQuery.validator.addMethod(“chekMatrix”,function(value, element) { var val=$(“#payInMatrix”).val(); var obj=$(“#matrix”).find(“option[value=’”+val+”‘]”) if(obj !=null && obj.length>0) { return true; } },’Please Enter only from list’);

JQuery Validation for AlphaNumeric Field

Posted on Leave a commentPosted in JQuery

jQuery.validator.addMethod(‘alphanum’, function(value, element) { return this.optional(element) || /^[a-z0-9]+$/i.test(value); }, “This field contain only letters and numbers.”);     Example:   $(‘#frm3’).validate({ rules: { roll: { alphanum:true } } }, errorClass: ‘help-block’, errorElement: ‘span’, highlight: function (element, errorClass, validClass) { $(element).parents(‘.form-group’).removeClass(‘has-success’).addClass(‘has-error’); }, unhighlight: function (element, errorClass, validClass) { $(element).parents(‘.form-group’).removeClass(‘has-error’).addClass(‘has-success’); } });