Nitin Kabra Nitin Kabra - 1 year ago 76
Javascript Question

Regular Expression for alphabets with spaces

I need help with regular expression. I need a expression which allows only alphabets with space for ex. college name.

I am using :

var regex = /^[a-zA-Z][a-zA-Z\\s]+$/;

but it's not working.

Answer Source

Just add the space to the [ ] :

var regex = /^[a-zA-Z ]*$/;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download