[英]input field can have only one character and 8 numbers
我正在嘗試設置,如果輸入字段末尾可以有 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)
它僅適用於任何 8 個數字。
嘗試
$( "input" ).attr("pattern", '^[0-9]{8}[A-Z]$').prop('required', true)
這將要求最后一個字符為大寫。 您可以在字符組中添加az
以允許不區分大小寫的字符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.