簡體   English   中英

驗證PHP中的ID號

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM