My validation accepts only alphabets. I want allow spaces as well.
$.validator.addMethod("alpha", function(value, element) { return this.optional(element) || value == value.match(/^[a-zA-Z]+$/); });
What change needs to be done here?
Advertisement
Answer
Instead of the below regex:
/^[a-zA-Z]+$/
Use this:
/^[a-zA-Zs]+$/
This will also take the space.