Answers for "javascript prevent writing special characters"

0

js remove special characters

var desired = stringToReplace.replace(/[^\w\s]/gi, '')
Posted by: Guest on September-23-2020
0

how to block special characters in javascript

var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

for (var i = 0; i < document.formname.fieldname.value.length; i++) {
    if (iChars.indexOf(document.formname.fieldname.value.charAt(i)) != -1) {
        alert ("Your username has special characters. \nThese are not allowed.\n Please remove them and try again.");
        return false;
    }
}
Posted by: Guest on January-24-2021

Code answers related to "javascript prevent writing special characters"

Code answers related to "Javascript"

Browse Popular Code Answers by Language