You must Sign In to post a response.
  • Category: JavaScript

    How to Set focus on text box after validation summary


    Are you looking for a way to Set focus on text box after validation summary ? then read this thread to know how to set it



    i want to show validation summary in popup and after "ok" click i want to focus the cursur on the first validate field(invalid control).and must be browser compatible.
  • #757350
    Hi,

    Check the below Jquerrycode for ur refences:

    $(document).ready(function () {
    $("#<%=btnOK.ClientID%>").click(function () {
    ValidateEmail();
    });

    });
    //Email Validation
    function ValidateTestbox() {
    var Value = $("#<%=txtboxID.ClientID%>").val();
    if ($.trim(Value ).length == '') {
    alert('Please enter email id');
    $("#<%=txtboxID.ClientID%>").focus();
    return false;

    }

    Hope this code help u out..

    Thanks,
    Chitaranjan

  • #757367
    You can Add a PageManager control to the page. Then use these properties to establish focus, see the following attributes
    1. FocusOnChange - Set the focus to the field after a change is made when there is a validation error. When true, focus is set on the field.
    2. FocusOnSubmit – Set focus to the first field that generates a validation error when the page is submitted. When true, focus is set on the field.
    3. FocusAfterAlert – Set focus to a field with an error after the alert is displayed when using the ErrorFormatters that display alerts. Supported by "Image with Alert" (AlertImageErrorFormatter) and "HyperLink with Alert" (HyperLinkErrorFormatter). When true, focus is set to the field after the alert is dismissed.
    for more detail switch to following link
    http://learningdes.peterblum.com/Validation/Validators/GettingAttention/Focus.aspx

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #757374
    ok,in my current application amusing the same you wrote,
    but i want other methods which reduce the javascript code, and reusable.


  • Sign In to post your comments