Reputation: 759
I'm using jQuery validation engine for the user registration form on my site and I'm looking for a way to implement an additional control to prevent the usage of special characters, only allowing the use of letters, numbers and the following characters: ,-'. I've tried the following rule, but it won't prevent the usage of: #;" for example. Can someone please tell me where I'm going wrong with the regex?
"noSpecialChars": {
"regex": /^[0-9a-zA-Z\ \'\-\,]+$/,
"alertText": "* Text contains invalid characters"
},
Upvotes: 0
Views: 1686