Special characters <, >, %, '', "", $ and ^ are not allowed in a textbox. I need to put a validation check to restrict these characters on submit along with the null check.
I wrote entire validation code in a function and calling it on click of the submit button, but the function is not recognised on click.
Please help me write some JavaScript code to achieve this functionality.
A much simpler way is to use indexOf in javascript,
function isSpclChar(){
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
if(document.qfrm.q.value.indexOf(iChars) != -1) {
alert ("The box has special characters. \nThese are not allowed.\n");
return false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With