Reputation: 498
This is the code I have:-
var exp = /[^0-9]/g;
if (!exp.test(char)) {
args.set_cancel(true);
I want to include special character check meaning I do not want special character to be entered (except backslash).
Upvotes: 0
Views: 150
Reputation: 785156
I do not want special character to be entered (except backslash).
You need to define what makes a special character.
Though you can probably use this regex: (as per comments below)
1st case:
var exp1 = /^[a-z]+\\\\[a-z\d]+$/ig;
Demo: http://regex101.com/r/kB1cN5
2nd case:
var exp2 = /^((?!.*?\d)(?!.*?[^\w\s]).)+$/g;
Upvotes: 1