[英]Validate id number in php
html格式的格式如下圖所示:
<tr style="height:15px;"><td></td></tr>
<tr>
<td>ID Card No<br /></td>
</tr>
<tr>
<td><input class="input" style="width:300" size="20" type="text" name="id" maxlength="5"/></td>
</tr>
如何以PHP格式驗證ID號(例如A1234)?
只需使用正則表達式即可接受one upper char and four digits
:
$str = 'A1234';
$result = preg_match('~^[A-Z]\d{4}$~', $str);
print_r($result); // true | false
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.