-2

请告诉我如何验证用户输入,仅限字母。

<form action="#" method="post" name="form1">
<table>
<tr>
<td id="CA_Tbl_Title">Name</td>
</tr>
<tr>
<td>
<input type="text" name="First_Name" onclick="make_blank_First();"    
autofocus="First_Name" id="Form_Input_User"
value="<?php echo $First_Name; ?>"/>
<span class="Error"><?php echo $Msg_First_Name; ?></span></p>
</td>
</tr>
</table>
</form>
4

1 回答 1

0

检查ctype_alpha方法。

bool ctype_alpha ( string $text )

检查提供的字符串 text 中的所有字符是否都是字母。在标准 C 语言环境中,字母只是[A-Za-z]并且ctype_alpha()等同于(ctype_upper($text) || ctype_lower($text))if$text只是单个字符,但其他语言的字母既不大写也不小写。

TRUE如果文本中的每个字符都是来自当前语言环境的字母,则返回,FALSE否则。

参考: http: //php.net/manual/en/function.ctype-alpha.php

于 2013-04-03T22:45:00.817 回答