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