Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检查对 HTML5 输入类型电子邮件失去焦点的验证?
<input type="email" name="useremail" onblur="setCustomValidity('Plz enter email ')" />
onchange 事件应该可以解决问题。
编辑:您可能只想验证值何时更改并且字段失去焦点,这就是 IMO onchange 事件比 onblur (不是 onblure)更合适的原因。
参考:stackoverflow.com/a/785106/440519