名字和名字的html5模式 [英] html5 pattern for first and last name

查看:94
本文介绍了名字和名字的html5模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a input box where the user can input the first name and last name. I have used html5 pattern for validation.

但问题是当你把西蒙然后它没关系但如果你写西蒙西蒙然后它不是(可能是问题是2个单词之间的空间)。我希望输入框允许两者

But the issue is when you put "Simon" then it's fine but if you write "Simon Simon" then it's not(Probably the problem is with the space between 2 words). I want the input box to allow both

1.Username

1.Username

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 /> 


推荐答案

1。什么是一个名字?你是说一个给定的名字?如果是这样,请记住,只有一部分全球人口将姓氏写为姓氏。你真的应该使用术语给定名称和姓氏。想想»艾未未« - 姓氏是艾。

1. What is a first name? Do you mean a given name? If so, please remember that only a part of the global population writes their family names as last names. You really should use the terms "given name" and "family name". Think about »Ai Weiwei« – the family name is »Ai«.

2。名称选项太多了。 [a-zA-Z] 甚至不包括所有北美或欧洲名字(想想»O'Doyle«)。系列名称也可能包含空格字符(如Mac Amhlaidh中所示)。拉丁语,法语,西班牙语或德语名称与口音或变音符号一起使用?那些非拉丁名字怎么样?你知道ВладимирПутин?

2. There are just too many options for names. [a-zA-Z ] does not even cover all North American or European names (think about »O'Doyle«). Family names may also contain a space character (as in »Mac Amhlaidh«). Staying with latin, what about French, Spanish or German names with accents or umlauts? And what about non-latin names? You know Владимир Путин?

3。你真的应该使用两个不同的输入字段。 不要对不规则的人使用正则表达式。

3. You really should use two distinct input fields. Do not use a regular expression on something that irregular like a persons name.

这篇关于名字和名字的html5模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆