So two questions here: If I use <input type="button" onclick="validate()"> then the enter key wouldn’t work. However, I can use type="submit" but how would I invoke validate()?
So two questions here: If I use <input type=button onclick=validate()> then the enter key
Share
You can have the form validate on submit, which is better anyways:
You can return
falsefrom your validation function to prevent the form from submitting. The form will validate regardless of whether it’s submitted via the return key or the button being clicked.