default button on form

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
 
C

Chris Jackson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top