我想使用模式/^[a-zA-ZÀ-ÖØ-öø-ÿ+\.+\- ]+$/i
来验证<input>
字段中的名称。但在HTML验证中,这种方法不起作用。之前我使用过pristine.js,它可以轻松地解决这个问题。
我还创建了一个JS Fiddle: https://jsfiddle.net/3et69oz8/:
<form>
<input id="first name" name="first_name" required
pattern="/^[a-zA-ZÀ-ÖØ-öø-ÿ+\.+\- ]+$/i">
<button>Submit</button>
</form>
"^[a-zA-ZÀ-ÖØ-öø-ÿ+\.+\- ]+$"
。 - Ishan