monda monda - 1 year ago 137
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 ?

Answer Source

Instead of the below regex:


Use this:


This will also take the space.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download