Change Border of TextBox On Text Change or Focus

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2011

    Posted 18 Feb 2011 Link to this post

    I am wanting to validate based on a complex set of rules the entry into a textbox.  My preference would be to keep that validation on the server side in the code behind as the logic is written there already so I do not want to maintain it in javascript too for client side validation.  How can I call a validation method either on text change or focus via ajax with this control?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Feb 2011 Link to this post

    Hello Jeff,

    You can use the CustomValidator to achieve the scenario. There you can attach the OnServerValidate event and set the TextBox property CausesValidation to true. Your aspx should be like this.
    <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="a" CausesValidation="true"
    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="ErrorMessage!!"
                OnServerValidate="ValidateNumber" ValidationGroup="a">

Back to Top