我有一个文本字段,它只接受NEXT NEXT ALPHANUMERIC,单个字母表接下来是单个数字例如: - s3f4G5A2s3

时间:2014-12-02 13:11:31

标签: regex

HTML:

input type =“text”id =“custom_expression”

的javascript:

script src =“http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”

$(document).ready(function()

{

$(函数()

{

$( '#custom_Expression')。按键(函数(e)中

{

var txt = String.fromCharCode(e.which);

console.log(txt +':'+ e.which);

如果(!txt.match(/ ^([A-ZA-Z] [0-9]){3} $ / g)的

{

返回false;

}

});

});

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

  

(([A-Z] | [A-Z])+ [0-9]){3}

并在此测试: http://regex101.com