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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top