Setting form focus!

I have two submit buttons on the page, one a login (top of the page) and the other a search box (half-way down).

When entering text in the search box and then clicking submit the login box validation method is called (javascript popup).

How can I make the search box submit instead of the login? :confused:

Do they have the same identifier (id=“submitButton”) ?

Keep IDs unique for different elements.

You can also use different Validation Groups too if you’re validating more than one form on a page.

You may also want to use <asp:Panel> with the DefaultButton attribute.

They have separate ID’s.

The issue is when pressing enter after the text in the search box. The form at the top of the page attempts to submit.

I have tried placing the login form at the bottom of the page but problem still persists!

Thanks imaginekitty… I have done this but problem still occurs. This must be due to the javascript code I have implemented on the login box… I will check and get back to you guys/girls!

Many thanks.

Can you show the code?


This is the validation control for the login area:

<asp:ValidationSummary ID=“valLogin” runat=“server” EnableClientScript=“true” ShowMessageBox=“true” ShowSummary=“false” EnableViewState=“false” ValidationGroup=“mainlogin” HeaderText=“Sorry could not perform your login request because:” />

This is triggered whenever the enter key is pressed in the search area of the page.


Where’s the rest of the validation group and the panels?

Sorry here goes:

<asp:CustomValidator ID=“uxAuthenticateValidator” runat=“server” ErrorMessage=“Your email address and password were invalid.” EnableClientScript=“true” Display=“none” OnServerValidate=“ValidateCredentials” ValidateEmptyText=“false” ValidationGroup=“mainlogin” /><asp:RequiredFieldValidator ID=“uxEmailValReq” runat=“server” ControlToValidate=“uxEmailAddress” ErrorMessage=“You must enter your email address.” EnableClientScript=“true” Display=“none” ValidationGroup=“mainlogin” /><asp:RequiredFieldValidator ID=“uxPasswordValReq” runat=“server” ControlToValidate=“uxPassword” ErrorMessage=“You must enter your password.” EnableClientScript=“false” Display=“none” ValidationGroup=“mainlogin” />
<p><span id=“email-text”><input name=“email_temp” type=“text” value=“Email” class=“login-email-i” maxlength=“20” onfocus=“changeBox(‘email’)” /></span><span id=“email-enter” style=“display:none;”><asp:TextBox ID=“uxEmailAddress” runat=“server” cssclass=“login-email” TabIndex=“900” ToolTip=“your email address” ValidationGroup=“mainlogin” CausesValidation=“true” AutoCompleteType=“Email”/></span> <span id=“password-enter” style=“display:none;”><asp:TextBox ID=“uxPassword” runat=“server” TextMode=“Password” cssclass=“login-pwd” TabIndex=“901” ToolTip=“your password” ValidationGroup=“mainlogin” CausesValidation=“true”/></span><span id=“password-text”><input name=“pass_temp” type=“text” value=“Password” class=“login-pwd-i” maxlength=“20” tabindex=“902” onfocus=“changeBox(‘pass’)” /></span> <asp:Button ID=“uxLogin” runat=“server” Text=“Login” cssclass=“loginbutton” TabIndex=“904” ValidationGroup=“mainlogin” CausesValidation=“true” ToolTip=“Login to xxx”/> <asp:button id=“uxForgotten” runat=“server” cssclass=“loginbutton” text=“?” CausesValidation=“false” ToolTip=“Forgotten password” TabIndex=“905”/> <asp:button id=“uxRegister” runat=“server” cssclass=“loginbutton2” text=“Register” CausesValidation=“false” ToolTip=“Register on xxx” TabIndex=“906”/></p>