0
votes

net application, in that i have many required field text boxes in Tabcontrol in both tab panels.

when i have clicked submit button, it only focus current tab text box controls, but when i filled all the current tab panel controls then press submit button, i want to focus the next tab panel text box which is empty,

but it can't focus on another tab panel textbox.

i don't know how to focus this, please any body let me know.

required="required"

enter image description here

enter image description here

<td><asp:Label ID="lblCustomerMobileNo" runat="server" Text="Customer Mobile No" CssClass="label"></asp:Label></td>

<td><asp:TextBox ID="txtCustomerMobileNo" runat="server" CssClass="smalltextbox" PlaceHolder="Customer Mobile No" Width="100px" MaxLength="10" OnKeypress="javascript:return onlyNumbers(event,this.value);"
required="required" /> </td>

when i am in TAB 4, i press save button it focus required text box.

but i filled customer mobile no, and then press save button TAB 0 also having some required field text boxes but its not focus..

2
code..........?Imad
@Imad updated, pls check..Surya
How are you switching tabs?Imad
by using mouse click only.. i need focus which field is required in another tab panel.Surya
of course by mouse but I am asking about code.Imad

2 Answers

0
votes

you can use javascript function to check fields and focus in tab which has empty field. or in server side check fields and set active tab

0
votes

If you use the build-in aspnet Validation Controls, you have the SetFocusOnError property.

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
    ErrorMessage="Field is required" ValidationGroup="myForm" ControlToValidate="TextBox1"
    SetFocusOnError="true"></asp:RequiredFieldValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="myForm" />