var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/; if(format.test(string)){ return true; } else { return false; }
return mystring.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
escape sequences in javascript \' single quote \" doucle quote \\ backslash \n newline \r carriage return \t tab \b backspace \f form feed
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"));