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:
And my control:
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
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