I have a javascript code which is supposed to test if some special characters are in a string like this:
var string = prompt("write something here","hello");
if(string.search("+") != -1){alert("special character")}
if(string.search("(") != -1){alert("special character")}
if(string.search(")") != -1){alert("special character")}
if(string.search("[") != -1){alert("special character")}
if(string.search("]") != -1){alert("special character")}
if(string.search("*") != -1){alert("special character")}
if(string.search("\\") != -1){alert("special character")}
For all the special characters above, it shows me an error message (which is different according to the special character, for + and * it says "unexpected quantificator" and for the others it says something about a regular expression). Why does it do that and what solutions are there? (I'm using HTA so don't suggest any HTML5-solutions)