Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 输入字段只能有一个字符和8个数字_Html_Jquery - Fatal编程技术网

Html 输入字段只能有一个字符和8个数字

Html 输入字段只能有一个字符和8个数字,html,jquery,Html,Jquery,我试图设置,如果输入字段可以有8位数字和一个字母结尾, 示例:25639154R 我的代码: <form> <input type="text" class="form-control" id="paycheck" /> <input type="submit" /> </form> $( "input" ).attr("

我试图设置,如果输入字段可以有8位数字和一个字母结尾, 示例:25639154R

我的代码:

<form>
    <input type="text" class="form-control" id="paycheck" />
    <input type="submit" />
</form>

$( "input" ).attr("pattern", '^[A-z]{1}||^[0-9]{8}').prop('required', true)

$(“输入”).attr(“模式”,“^[A-z]{1}}| ^[0-9]{8}”).prop('required',true)
它只适用于任何8个数字。

试试看

$( "input" ).attr("pattern", '^[0-9]{8}[A-Z]$').prop('required', true)
这将要求最后一个字符为大写。您可以在字符组中添加
a-z
,以允许不区分大小写的字符