I’m implementing a web application. Here, I’m struggling with a form validation. I just want to know how to allow the user to type letters, numbers and the apostrophe character in a text field using jQuery form validation method. Here with the question, I’m putting a sample code of the validation I have implemented.
jQuery.validator.addMethod("business_name", function(value, element) {
return this.optional(element) || /^[a-zA-Z0-9\']+$/i.test(jQuery.trim(value));
}, "");
Simple you need to pass
As regex, it will solve your problem