1var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
2
3if(format.test(string)){
4 return true;
5} else {
6 return false;
7}
1var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
2// ^ ^
3document.write(format.test("My@string-with(some%text)") + "<br/>");
4document.write(format.test("My string with spaces") + "<br/>");
5document.write(format.test("MyStringContainingNoSpecialChars"));