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"
},
this catches only sequences of chars case-insensitive, numbers and
'-,without spaces! If you allow spaces only add\.after theZ.you can test it here