Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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. 
These are not allowed.
 Please remove them and try again.");
        return false;
    }
}
Comment

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. 
These are not allowed.
 Please remove them and try again.");
        return false;
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: firebase get current user javascript 
Javascript :: get message by id discord.js 
Javascript :: vanilla tilt.js 
Javascript :: javascript division get remainder 
Javascript :: react native go to next text input 
Javascript :: js simulate keyboard input 
Javascript :: index.js vs main.js 
Javascript :: unable to resolve path to module eslint(import/no-unresolved) absoute path 
Javascript :: jquery all elements whose id contains 
Javascript :: style after javascript 
Javascript :: javascript toggle value 
Javascript :: javascript change color of button 
Javascript :: js append query string to url 
Javascript :: fibonacci recursion javascript 
Javascript :: current height minus px 
Javascript :: change header background color on scroll css 
Javascript :: ReferenceError: window is not defined 
Javascript :: javascript filter strings for partial matches 
Javascript :: express messages 
Javascript :: await set timeout 
Javascript :: express draft 
Javascript :: match date regex 
Javascript :: how use replace in js for all things at once 
Javascript :: javascript get all keys of object 
Javascript :: nuxt redirect traffic from http to https 
Javascript :: cy url contains 
Javascript :: nodejs check if variable is undefined 
Javascript :: how to read write object to localStorage in js 
Javascript :: How to know react and react-native version 
Javascript :: axios pass params 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =