This is a migrated thread and some comments may be shown as answers.

Client-side Validaiton of Numeric and Date Input Controls

1 Answer 115 Views
Input
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 06 Feb 2009, 03:45 PM
Is there a way to query whether or not the value of a RadNumericTextBox or a RadDateInput is valid on the client side? I want to re-validate all the input fields on the screen when the user clicks a submit button and halt that postback action if any of the values are invalid.

I have three types of controls I'm using: RadTextBox, RadNumericTextBox, and RadDateInput. I validate the RadTextBox values client-side by comparing them against a preconfigured regular expression. I can do this for both the Numeric and Date controls as well, but was hoping there was an easier built in function to check the validity of the contents.

Thanks,
Andrew

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 09 Feb 2009, 07:15 PM

Hello Andrew,

You can handle the OnError client event of the date input to process some custom logic when the user enters invalid input/the date is out of range.

For this case you have to replace the invalid entry with a new date value from an array depending on whether the pattern is recognized as incompatible/outside of the date range bounds. The code resides in the HandleDateParseError/HandleDateOutOfRange javascript methods. The date must be set via the property SelectedDate by set_selectedDate(date) from the client-side API of the date input.

You can find more information about  Handle OnError Event  on the following links:
OnError event  Demo
Help topic

I hope this information helps.

Greetings,

Pavlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Input
Asked by
Andrew
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or