default button on form

  • Thread starter Thread starter Bratislav Jevtic
  • Start date Start date
B

Bratislav Jevtic

hi,

how to make some push button default on the form? for instance, I've got 2
buttons (Submit, Cancel). submit is on the left, cancel on the right side.
on enter key pressed, cancel button is processed - wrong. so, how to make a
button default (when one presses ENTER then it's processed onClick event)?

thanks,
bj
 
From MSDN:

When there is more than one INPUT type=submit in the same form, pressing
enter submits the form using the first INPUT type=submit, unless another
INPUT type=submit has focus. When another INPUT type=submit has focus,
pressing enter submits the form using that INPUT type=submit.

If you don't like this behavior, you can use JavaScript to trap the
OnKeyPress event, and if it is the enter key (13), fire the click method of
the button you want to be the default.
 
Back
Top