Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.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
使用HTML5模式进行名字验证_Html_Validation_Design Patterns - Fatal编程技术网

使用HTML5模式进行名字验证

使用HTML5模式进行名字验证,html,validation,design-patterns,Html,Validation,Design Patterns,我有这个密码 echo '<input type="text" maxlength="32" name="first_name" pattern="[A-Za-z]" value="'.$_SESSION['user_first_name'].'" required>'; echo'; 即使我把某些内容更正了,它也会说“请匹配所需的格式” 数据为“testme”,这是正确的,但未通过验证。您需要指定模式的长度pattern=“[A-Za-z]{1,32}” echo'; pat

我有这个密码

 echo '<input type="text" maxlength="32" name="first_name" pattern="[A-Za-z]" value="'.$_SESSION['user_first_name'].'" required>';
echo';
即使我把某些内容更正了,它也会说“请匹配所需的格式”


数据为“testme”,这是正确的,但未通过验证。

您需要指定模式的长度
pattern=“[A-Za-z]{1,32}”

echo';
pattern=“[A-Za-z]{1,32}”
用于数据“testme”(它有6个字符)

echo'

或者你可以给出一个有范围的图案

echo'


在这种情况下,您可以输入1到255个字符作为输入值

Do
echo
HTML,而不是在2014年。使用任何模板系统[Twig,Handlebar,随便什么]。再次抱歉,这是我的错误。现在它正在工作。谢谢。
echo '<input type="text" maxlength="32" name="first_name" pattern="[A-Za-z]{1,32}" value="'.$_SESSION['user_first_name'].'" required>';