【发布时间】:2018-12-27 11:39:20
【问题描述】:
我只想在“john deo”之类的输入框中允许输入字母和空格。但以上不适用于下面的正则表达式,并且不允许空间。
<!DOCTYPE html">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<body>
<label>full name
<input type="text" name="textfield" onkeydown="return /[a-z]/i.test(event.key)"
onblur="if (this.value == '') {this.value = '';}"
onfocus="if (this.value == '') {this.value = '';}"/>
</label>
</body>
</html>
【问题讨论】:
-
您要允许多少个空格?