I'm not sure when you want to do this check, but here's a function to do the checking. It will alert the first non-valid character.
function checkValue(input) {
var result = /[^a-z0-9 !#%&*()+\-=,.?"';:\/]/i.exec(input.value);
if (result) {
alert("Character '" + result[0] + "' is not allowed");
return false;
} else {
return true;
}
}
If you want all the matched non-valid characters, then you could use the following:
function checkValue(input) {
var isValid = true, result, matchedChars = [];
while( (result = /[^a-z0-9 !#%&*()+\-=,.?"';:\/]/ig.exec(input.value)) ) {
matchedChars.push("'" + result[0] + "'");
isValid = false;
}
if (!isValid) {
alert("Characters " + matchedChars.join(", ") + " are not allowed");
}
return isValid;
}