regex - Regular Expression for Alphanumeric, Hyphen and Space -
i have regular expression checks if string contains alphanumeric , hyphen.
this regular expression alphanumeric validation only:
var numericreg = /^([a-za-z0-9]){1,20}$/;
to which, need include hyphen , space too.
that means, value "100-c09d10 a" must possible enter.
try this
^([-a-za-z0-9]){1,20}$ or this
^([a-za-z0-9-]){1,20}$ i think using js. should work. check here. if want include space add space in character class
^([-a-za-z0-9 ]){1,20}$ always remember - in character class used denoting range usually. if want include hyphen should either add beginning or end of character class or \ suggested in other answer
Comments
Post a Comment