I am using the jquery-validation
plugin to validate a simple form. It's working great.
Is it possible to restrict the keys from being typed in the textbox
completely.
I got this FIDDLE which is somewhat close to what I want.
<form id="myform" method="post" action="">
<input type="text" id="cstName" name="cstName" />
<input type="text" id="cntNumber" name="cntNumber" />
<input type="submit" id="btn" name="btnSubmit" value="Submit" />
</form>
$.validator.addMethod(
"regex",
function (value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(element);
},
"Please check your input."
);
$(document).ready(function () {
$("#myform").validate({
rules: {
cstName: {
required: true, regex: /^[0-9\.\-\/]+$/
},
cntNumber: {
required: true
}
}
});
});
Here is a simple form created in my MYFIDDLE.
Can the words be restricted from being typed using the jquery-validate
plugin. And while it restricts, can the error message still be shown??