Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.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
Regex 名字和姓氏的html5模式_Regex_Html - Fatal编程技术网

Regex 名字和姓氏的html5模式

Regex 名字和姓氏的html5模式,regex,html,Regex,Html,我有一个输入框,用户可以在其中输入名字和姓氏。我使用html5模式进行验证 但问题是当你写Simon的时候没关系,但是如果你写Simon Simon的话,问题不在于两个单词之间的空格。我希望输入框同时允许这两种情况 1.用户名 2.名字和姓氏 我的代码是 <input id="login_input_username" pattern="[a-zA-Z]{2,64}" class="login_input" type="text" name="user_full_name" onfocu

我有一个输入框,用户可以在其中输入名字和姓氏。我使用html5模式进行验证

但问题是当你写Simon的时候没关系,但是如果你写Simon Simon的话,问题不在于两个单词之间的空格。我希望输入框同时允许这两种情况

1.用户名

2.名字和姓氏

我的代码是

 <input id="login_input_username" pattern="[a-zA-Z]{2,64}" class="login_input" type="text" name="user_full_name" onfocus="this.value=''" onblur="(this.value=='')? this.value='Firstname lastname':this.value;" value="Firstname lastname" required /> 
一,。名字是什么?你是说一个名字吗?如果是这样,请记住,全球人口中只有一部分人将姓氏作为姓氏。你真的应该用名字和姓氏。想想»艾未未«–姓氏是»艾未未«

二,。名字的选择太多了。[a-zA-Z]甚至没有涵盖所有北美或欧洲的名字,比如»O'Doyle«。族名称也可以包含空格字符,如»Mac Amhlaidh«。如果继续使用拉丁语,那么法语、西班牙语或德语中带有重音或元音的名字呢?那么非拉丁名字呢?你知道吗


三,。您确实应该使用两个不同的输入字段。不要在不规则的东西上使用正则表达式,例如人名。

[a-zA-Z]{2,64}。。。。。。。。。。使用这种模式。我在你的模式中在Z后面加了空格谢谢,但我试过了。不幸的是没有用。请注意,名称不是唯一的,你不应该将其用作登录参数。非常感谢你澄清这一点。这真的很有趣。