Link to home
Start Free TrialLog in
Avatar of gleznov
gleznov

asked on

Web app - need to stop enter key from triggering a button.

Hi,

     I'm designing a VB.NET webform that has a small javascript that places the focus initially in a textbox.  At the bottom are buttons - Add/Edit/Cancel/Delete.  When I hit the enter key at any point on this form, the Add button is triggered (although a few times it's been edit) which disrupts the form.  I want the user to have to click the buttons, or later I will program so that depending on what text box the focus is in triggers different buttons.  I don't ever want enter key to trigger the Add button.  I need a javascript either in my HTML side or that I can just submit the way I do my focus:

            Dim strScript As String = "<script language=JavaScript> document.all('txtScanStock').focus(); </script>"
            Page.RegisterStartupScript("MyScript", strScript)

that will keep the enter key from submitting random buttons, or any at all.  Can someone help me?  Thanks!

JP
ASKER CERTIFIED SOLUTION
Avatar of dakyd
dakyd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gleznov
gleznov

ASKER

That's absolutely perfect!!!

JP