I want to validate a string in JavaScript to allow alphanumerics, "(", ")" , and spaces. So test strings are:
s1 = "This $h00l*&^ not w0rk342*_(&, <and> always fail"
s2 = "This should work (ABC1234)"
my code:
var regX = new RegExp(/A-Za-z0-9\\(\\)\\x20+/);
if(!regX.test(s1)){
alert("InValid value.");
}
But it fails for both the strings.
Also as test() function evaluates the matches in the string and not the whole string https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
Can someone please help. Thanks in advance