I have a text field, which will accept only the NEXT TO NEXT ALPHANUMERIC that is single alphabet next is single numeric FOR EXAMPLE:- s3f4G5A2s3
JavaScript的:
script src ="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
$(文件)。就绪(函数()
{
$(函数(){
$( '#custom_Expression')。按键(功能(E){
var txt = String.fromCharCode(e.which);
console.log(txt +':'+ e.which);
1 2 3 4 5 6 7 | if(!txt.match(/^([a-zA-Z][0-9]){3}$/g)) { return false; } }); }); |
input type ="text"id ="custom_expression"
要允许单个字母后跟单个数字,一次或多次在
1 | var re= /^([a-zA-Z][0-9])+$/g; |
要么
1 | var re= /^([a-zA-Z][0-9]){3}$/g; |
repitition quantifier