RadDateInput - Can't tell error state.

2 posts, 0 answers
  1. Sean Overman
    Sean Overman avatar
    31 posts
    Member since:
    Sep 2012

    Posted 18 Sep 2009 Link to this post

    First let me lay out the situation.   I have a Date Field that is not required.  But I would like this field to still be validated when data is entered. So, therefore I'm using the RadDateInput field and a custom validator.

    I tried to implement a solution by subscribing to the Error event, and keeping track of the state.  But the problem is that when it enters error state, then you clear the text box, you don't know that you "cleared" the error, and the form doesn't validate.

    Here is the javascript i'm using:
            var invalidInput = false
     
            function OnValueChanged(sender, args) { 
                if (!(invalidInput && args.get_newValue() == "")) { 
                    invalidInput = false
                } 
            } 
     
            function OnError(sender, args) { 
                invalidInput = true
            } 
     
            function CustomValidate(sender, args) { 
                if (invalidInput) { 
                    args.IsValid = false
                } 
            }   

    And my control:
    <tel:RadDateInput runat="server" id="DOB" MinDate="1/2/1900"
        <ClientEvents OnValueChanged="OnValueChanged" OnError="OnError" /> 
    </tel:RadDateInput> 
    <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="DOB" ClientValidationFunction="CustomValidate" ErrorMessage="*" ValidateEmptyText="true" /> 
     

    So, is there a way to check to see if the RadDateInput control is in "Error" state (red w/ Exclamation)?

    You can reproduce this by using the code attached and following these steps.
    #1 Set the date to something invalid ("asdf")
    #2 tab out ( notice the Telerik Error state and the custom validator message '*" )
    #3 Submit the form. (notice the validation error)
    #4 clear the textbox
    #5 tab out (notice he Telerik error state has been cleared, but the validation error still persists)
    #6 submit the form( it wont submit because the custom validator has not been cleared)

    Any help in resolving the validator issue, or giving me a solution where the Data in the RadDateInput is still validated but stops the form from submitting w/ errors while still allowing an "empty" state where the data not "required".

    Thanks,
    Sean

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 24 Sep 2009 Link to this post

    Hi Sean,

    You can check the errorcode, to see if this is a parse error, or out of bounds error. Additionally, what is the logic which you are handling via the custom validator? One possible option may be to remove the custom validator for the date input control, and validate the input manually, when the user tabs out - given that the logic is not too complex.

    Sincerely yours,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top