Reputation: 252
I have a text field which accepts only one character but if user enters any escape characters such as \n, \t, \s, etc it should be allowing it even though it has 2 characters.
I am using jquery.validationEngine to validate the text field but failing to parse it as per my desire.
Upvotes: 1
Views: 132
Reputation: 114491
A regular expression for that could be
[^\\]|\\[tns]
Meaning
t
, n
or s
Note that if you need to put this in a string literal then backslashes must be doubled again (doubled once for the string and doubled again to escape their special meaning in a regexp).
Upvotes: 1