monda monda - 5 months ago 32x
Javascript Question

Jquery Validation: allow only alphabets and spaces

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 need to be done here ?


Instead of the below regex:


Use this:


This will also take the space.