I am validating a textbox (specifically, a Telerik RadTextBox, but I don't think that is the problem). I've tried both RequiredFieldValidator and CustomValidator. When I press Tab, validation works fine, and it looks like the cursor goes to the next control. However, it takes an additional click for the next control to get focus. That is awkward on a page with multiple textboxes.
I think the problem has something to do with validation consuming the click, which prevents focus from moving to the next control.
How can I implement textbox validation such that tabbing or clicking out of the control both validates and focuses on the next control as expected?
This is C# webforms.
<telerik:RadTextBox ID="txtMyTextbox" runat="server" AutoPostBack="true"
RenderMode="Lightweight" style="max-width:none;" Resize="None" Width="330px"
TextMode="MultiLine" Rows="2" cols="66" class="TextAreaClass" >
</telerik:RadTextBox>
<asp:CustomValidator ID="valMyTextbox" runat="server"
OnServerValidate="Validate_txtMyTextbox_SS"
ValidationGroup="vgPage04" ValidateEmptyText="True"
Display="Static" CssClass="cssRF_splat"
Text="*" ErrorMessage="How Did Incident Occur">
</asp:CustomValidator>
on both IsPostBack and !IsPostBack, Page_Load calls Page.Validate();
protected void Validate_txtMyTextbox_SS(object source, ServerValidateEventArgs args)
{
args.IsValid = !string.IsNullOrWhiteSpace(txtMyTextbox.Text);
}
Thanks!