我想在输入框中只允许字母和空格,比如“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>