jquery - Preventing form submittion with enter key on all but one submit button -


I have an ASPX web form master page that has two submit buttons, login for another site search for account login I want to enter the key to submit for, but not for any other button on the site because the login is used more often. Every time I enter some login information and hit the hit, the search button gets fired and takes me to a blank result page. The following I have tried without success:

1) Enter the enter button type = and all other bus type = buttons

2) Defined for all UseSubmitBehavior = "false "In addition to the login button which is set to true. 3) Use different JQuery code on the input ID to disable the keyring input key for the input key.

The code only had an effect, however, it disables the key for everything, when I replaced the window for a selector, it failed to work. Since the whole page is a form, I did not add additional form tags. There should be a way to allow the entry key to work on just one button. Thanks

  $ (function () {$ (window) .keydown (event (event) {if (event.keyCode == 13) {event.preventDefault (); return false;}} );}); Search: & lt; Div id = "searchform" & gt; & Lt; Fieldset & gt; & Lt; ASP: Text Box ID = "Search Serving" Runat = "Server" Size = "15" /> & Lt; / Fieldset & gt; & Lt; ASP: ImageButton id = "searchButton" runat = "server" onmouseover = "this.src = '/ resource / button / search_hover.png' 'onmouseout =" this.src =' / resource / button / search_active.png '"image Url = "/ resource / button / search_active.png" type = "button" style = "font-size: 11px;" class = "searchbtn" alt = "search" onclick = "searchButton_Click" UseSubmitBehavior = "false" CausesValidation = " False "/> & Lt; / Div & gt; Login: & lt; Div id = "logonbox" & gt; & Lt; Asp: Label ID = "Label1" class = "LoginLabel1" runat = "server" text = "account number" & gt; & Lt; / Asp: Label & gt; & Lt; ASP: text box id = "actonum" class = "act pneumatoxbox" runat = "server" & gt; & Lt; / Asp: text box & gt; & Lt; Asp: Label ID = "Label2" runat = "server" class = "loginLabel2" text = "access code" & gt; & Lt; / Asp: Label & gt; & Lt; ASP: Text Box ID = "MTNL" class = "MTNLTXbox" Runat = "Server" & gt; & Lt; / Asp: text box & gt; & Lt; ASP: ImageButton id = "Login1" type = "submit" runat = "server" class = "boxsubmitbtn" src = "/ resource / button / login.gif" onclick = "LogInBtn_Click" UseSubmitBehavior = "true" CausesValidation = "false "/> & Lt; P & gt; & Lt; A href = "/ accounting / accounts.aspx" & gt; Need help signing in? & Lt; / A & gt; & Lt; / P & gt; & Lt; / Div & gt;  

There are several ways to achieve what you want, I know the easiest:

Add this line to your code in the page load method:

  Protected Zero Page_Load (Object Sender, EventArgs e) {this.Form.DefaultButton = Login1. UniqueID; }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -