admin管理员组文章数量:1277270
I have used
"^[a-zA-Z0-9]*$"
for alphanumeric no spaces its working
now i have to limit only 9 character are allowed not more not less only 9
I have used
"^[a-zA-Z0-9]*$"
for alphanumeric no spaces its working
now i have to limit only 9 character are allowed not more not less only 9
Share Improve this question asked Apr 24, 2013 at 6:53 Rahul ChowdhuryRahul Chowdhury 1,1586 gold badges32 silver badges58 bronze badges 1- "^[a-zA-Z0-9]*$" allows empty string while "^[a-zA-Z0-9]+$" requires at least one character. – Rick Putnam Commented Jul 7, 2015 at 19:43
2 Answers
Reset to default 12You can use curly braces to set limits on repetition:
"^[a-zA-Z0-9]{9}$"
That will only match strings in which the pattern in the character class is repeated exactly 9 times.
Note that you can also use this to limit repetition to a range. This example would only match strings in which the character class pattern is repeated between 3 and 5 times:
"^[a-zA-Z0-9]{3,5}$"
And you can leave out the second number but keep the ma to specify a minimum number of repetitions, so this one will match "at least 5":
"^[a-zA-Z0-9]{5,}$"
The simplest way is to use Range Validator with your regular expression validator. or go with James Allardice solution, it may also help you. but I will suggest to use Range Validator as well with your Regular Expression click
本文标签: javascriptregular expression for Alpha numericno spaces and 9 character inputStack Overflow
版权声明:本文标题:javascript - regular expression for Alpha numeric,no spaces and 9 character input? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741201535a2357321.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论