Hi all
I've been trying to find a regular expression that checks if input contains any of the following characters only:
`~!@#$%^&*()-=+\|/?.>,<;:'"[{]}
I want to allow users to input any normal character a-z or any numbers as well as underscores and any special character that resembles a letter such as é, ê, ô or ÿ etc
So far I have the following which doesn't allow for any of the special characters that I want to allow users to use:
/[^\w\s]/g
The code i'm using is as follows:
function checkName (strng) {
var error = "";
var illegalChars = /[^\w\s]/g; // allow letters, numbers, and underscores
if (strng == "") {
error = "Please enter your name.\n";
}
else if((strng.length < 2)) {
error = "The name is the wrong length.\n";
}
else if (illegalChars.test(strng)) {
error = "The name contains illegal characters.\n";
}
return error;
}