Been awhile since I needed to do this and I'm just not seeing what the problem is - maybe I'm just burned out too much right now.
var url = '/some-test.php?t=a-t!est&f=&c=4564646&u=4546&ds=45646&de=1254';
if( /^[a-zA-Z0-9\/\-\.\?\=\&]/i.test(url) ) {
console.log('true');
} else {
console.log('false');
}
Why is this passing true with 't!est' in the string?
My goal here is to make sure the string is only comprised of :
a-z
A-Z
0-9
/
-
.
?
=
&
case insensitive
I just want to do a quick and simple validation of url (or anything else) before using it... making sure it is only comprised of the characters I specify.