RadDatePicker and ValidatorUpdateDisplay

1 Answer 39 Views
DatePicker
John
Top achievements
Rank 1
John asked on 08 Nov 2024, 03:43 PM | edited on 08 Nov 2024, 03:45 PM

I am using a function that updates the style of the input controls on a webform.

<script>
$(function () {
if (typeof ValidatorUpdateDisplay != 'undefined') {
var originalValidatorUpdateDisplay = ValidatorUpdateDisplay;
ValidatorUpdateDisplay = function (val) {
if (!val.isvalid) {
$("#" + val.controltovalidate).css("border", "1px solid #C00");
}
else {
$("#" + val.controltovalidate).css("border", "0px solid #777");
}
originalValidatorUpdateDisplay(val);
}
}
});
</script>

<telerik:RadDatePicker ID="rdpServiceDateFrom" runat="server" MinDate="1/1/1900" MaxDate='<%# Now() %>' Width="100px" >
<Calendar ID="Calendar9" runat="server" ShowRowHeaders="false">
<SpecialDays>
<telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="#DDEEFF" />
</SpecialDays>
</Calendar><DateInput CssClass="requiredField" DateFormat="MM/dd/yy" Width="1"></DateInput>
</telerik:RadDatePicker>
<asp:RequiredFieldValidator ID="rfvrdpServiceDateFrom" runat="server" ControlToValidate="rdpServiceDateFrom" ErrorMessage="Service Date is required" ValidationGroup="ValidationGroupGetAProcedure" Display="None" />

All works well with other controls on the form (RadTextBox, RadDropdown, etc), but it cannot set the style on a RadDatePicker
Any ideas on how this can be modified or a workaround?

1 Answer, 1 is accepted

Sort by
0
Vasko
Telerik team
answered on 11 Nov 2024, 09:18 AM

Hello John,

From the code snippet, it appears you want to set a border to the DatePicker. To do that, you'll need to target the input element inside the DataPicker:

html body .RadPicker  input.riTextBox  {
    border: 1px solid;
    border-color: blue;
}

The current code used will have to check if val.controltovalidate is a DatePicker, which can be done by checking for a CSS class (for example "RadPicker"), and if it is, target the input child with the riTextBox class and add the CSS.

Regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Tags
DatePicker
Asked by
John
Top achievements
Rank 1
Answers by
Vasko
Telerik team
Share this question
or