I want to add/remove a class from the RadDatePicker when validation occurs, so I can change the border and font to red when it is invalid, and remove those styles when the user fixes the input. I've seen many posts in various forums asking this question or similar questions, but none of the suggestions work with the RadDatePicker.
What I want is a simple and common scenario:
- User selects a date
- Validation fires
- If invalid, change the color or other CSS properties of the control
- Change it back to the default when the user fixes the input
**Edit: I tried to attach a stripped-down version of my project that shows what I have so far, but the extension (ZIP) was not allowed. Please give me an email address to send it to if you'd like to see the sample code.** In the sample project, the problem can be demonstrated by selecting an end date less than the start date, which should trigger the validation. It works correctly in Chrome the first time - border turns red - but only when validation fails after editing the End Date. If validation fails because of changes to the Start Date, the ASP.NET validator picks that up but not the custom code. It's not a complete solution, but it's as far as I got because when I tested in IE I found that the change event doesn't fire at all.
What I really need, and I think many developers would agree, is a simple property on all the Rad controls such as "ErrorStyle" that sets the class used when a control fails validation. Please register that as a feature request.
In the meantime, I could use some help getting this to work with the current version of the date picker. One thing that might help is some information on the client-side events which fire during validation, and which HTML elements they fire from. The date picker has quite a complex hierarchy of elements in it, and I've been having trouble discovering how to hook into the right events. It would be nice if the datepicker had some kind of "onvalidated" event I could use. Failing that, is there a way to handle all validate events on the page, determine which control is a datepicker, and act accordingly?
What I want is a simple and common scenario:
- User selects a date
- Validation fires
- If invalid, change the color or other CSS properties of the control
- Change it back to the default when the user fixes the input
**Edit: I tried to attach a stripped-down version of my project that shows what I have so far, but the extension (ZIP) was not allowed. Please give me an email address to send it to if you'd like to see the sample code.** In the sample project, the problem can be demonstrated by selecting an end date less than the start date, which should trigger the validation. It works correctly in Chrome the first time - border turns red - but only when validation fails after editing the End Date. If validation fails because of changes to the Start Date, the ASP.NET validator picks that up but not the custom code. It's not a complete solution, but it's as far as I got because when I tested in IE I found that the change event doesn't fire at all.
What I really need, and I think many developers would agree, is a simple property on all the Rad controls such as "ErrorStyle" that sets the class used when a control fails validation. Please register that as a feature request.
In the meantime, I could use some help getting this to work with the current version of the date picker. One thing that might help is some information on the client-side events which fire during validation, and which HTML elements they fire from. The date picker has quite a complex hierarchy of elements in it, and I've been having trouble discovering how to hook into the right events. It would be nice if the datepicker had some kind of "onvalidated" event I could use. Failing that, is there a way to handle all validate events on the page, determine which control is a datepicker, and act accordingly?