regex - How to check whether the string has a starting character is special characters : javascript -
how find if starting character of string has special characters ?
the string can start alphanumeric should not start special characters.
if string starts special characters including space should alert user input invalid.
like this, testing whether first character of string in accepted range of [a-za-z0-9]
:
var s = "_whatever string_"; if(!/^[a-za-z0-9]/.test(s)) { alert ("invalid string"); }
Comments
Post a Comment