Fire html5 email validator on losing focus besides just on submission of forms

十年热恋 提交于 2019-12-06 13:31:40
Matt Browne

In Firefox, it should check the email for validity as you're typing by default (native HTML5 behavior): http://jsfiddle.net/xs65r/

But to support all HTML5 browsers, you'll need to manually call checkValidity() onblur and/or onkeydown.

See this link for more detail: HTML5 Chrome checkValidity onBlur

As you said in your comment below, you have to use the function this.checkValidity() in an if clause in your onblur function before making the ajax call, and dispay any errors yourself, since in browsers other than Firefox the native validation message UI isn't triggered unless the form is submitted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!