更新时间:2023-02-21 12:21:39
可以使用HTML5属性pattern
吗?请参见 MDN文章有关更多信息.
Can you use the HTML5 attribute pattern
? See the MDN article on it for more information.
使用^[a-zA-Z][\sa-zA-Z]*
的正则表达式似乎可以满足您的要求.
Using a regex of ^[a-zA-Z][\sa-zA-Z]*
seems to cover your requirements.
所以像这样:
<div>Username:</div>
<input type="text" pattern="^[a-zA-Z][\sa-zA-Z]*" title="Can use upper and lower letters, and spaces but must not start with a space" />