Reputation: 783
I'm using jQuery's validation plugin to validate a form. I have a field which should only contain letters or numbers. I have tried the following regex but it's still allowing characters such as ' ; :
[a-zA-Z 0-9]$
What am I doing wrong?
Thanks in advance
Upvotes: 1
Views: 5022
Reputation: 40170
Try this:
^[a-zA-Z 0-9]*$
If this is a required field, then change asterisk to plus:-
^[a-zA-Z 0-9]+$
Upvotes: 3