I'm working on a simple login form, with two fields:
<form>
<input type="email" name="email" required />
<input type="password" name="password" required />
<button type="submit">Log in</button>
</form>
For modern browsers, validation is automatically triggered.
However, if Javascript is available, I want to take over the html5 form validation, and handle everything myself.
I want to validate automatically 'onblur' (only the affected field) and I want to validate all fields when 'submit' is clicked.
The onblur events work fine, however.. When 'submit' is pressed, the standard 'submit' event is not triggered. However, an 'invalid' event is triggered; but only for the first invalid event.
What's a nice way to tell the browser to ignore all HTML5-related validation, and take over the entire process?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…