tags:

views:

46

answers:

1

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()?

+3  A: 

You can have the form validate on submit, which is better anyways:

<form ... onsubmit="return validate()">

    <input type="submit" />
</form>

You can return false from 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.

meagar
Thanks, Love you :)
Doug
@Doug Love me enough to accept my answer as correct? :)
meagar