Causesvalidation

6 posts, 0 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 02 Sep 2010 Link to this post

    Hi..
    I have a radcombox box in an ajax panel..
    The Causesvalidation does not fire unless I set AutoPostBack to true.
    Is this correct....?
    I need to validation to fire but I don't want to post back.
    thanks again
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 03 Sep 2010 Link to this post

    Hello Jon,

    That is correct, validation only fires if the control posts back, at least in the case when you use a CustomValidator control to do validation. Also, I don't quite understand your issue, do you want validation to occur on the combobox when a different item is selected or do you want validation on the rest of the form to be validated based on the selection made in the combobox. If you could expand on what you want to do or show us a simple version of your page.

    I hope that helps.
  3. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 03 Sep 2010 Link to this post

    The problem is I have a huge form.. and I dont' wanto postback to validate a the combobox... because on postback.. I change the current control focus and do other stuff....   I'm not a javascript guy and don't know how to write client side validation code (Convert my custom validator regularexpressions to JS)
    thanks
  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2815 posts

    Posted 07 Sep 2010 Link to this post

    Hi Jon,

    What is the expression that you're using. Perhaps we can help you with the conversion.

    Sincerely yours,
    Tsvetomir Tsonev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 07 Sep 2010 Link to this post

    Thanks...

     

     

    <asp:RegularExpressionValidator ID="valEMAIL" runat="server"

     

     

     

    ControlToValidate="txtEMAIL" ErrorMessage="* Improperly formatted Email address"

     

     

     

    Font-Bold="False" ForeColor="Red" SetFocusOnError="True"

     

     

     

    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

     

     

     

    Display="Dynamic"></asp:RegularExpressionValidator>

     



  6. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 13 Sep 2010 Link to this post

    Hello Jon,

    In fact ASP.NET validators can be fired at client-side with the ValidatorValidate method.
    You can handle OnClientBlur RadComboBox event (and optionally  OnClientSelectedIndexChanged event) and fire the RegularExpressionValidator in this manner:
    function OnClientBlurHandler(sender, eventArgs) {
        var regularExpressionValidator = document.getElementById('<%= valEMAIL.ClientID %>');
        ValidatorValidate(regularExpressionValidator);
         
        var requiredFieldValidator = document.getElementById('<%= RequiredFieldValidator1.ClientID %>');
        ValidatorValidate(requiredFieldValidator);
    }

    Additionally – please change the regular expression that you use from:
    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    to:
    ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

    I prepared for you a sample page in order to illustrate this approach – please find it attached.

    Best wishes,
    Kalina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top