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

Validate month

3 Answers 71 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ivy
Top achievements
Rank 1
Ivy asked on 22 Apr 2013, 02:40 PM
Hi,

How to check and validate that the month selected from the second radmonthyear picker comes after the month selected from first radmonthyearpicker?

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Apr 2013, 02:46 PM
Hi,

You can use ASP RequiredFieldValidator to ensure that both the fields are not left blank and an ASP CompareValidator to make sure that the second date selection comes after the first. Please have a look at the below mark up.

ASPX:
<asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="RadMonthYearPicker2"
    ControlToCompare="RadMonthYearPicker1" Operator="GreaterThan" Type="Date" ErrorMessage="The second date must be after the first one.<br /><br />">
</asp:CompareValidator>

Thanks,
Princy.
0
Ivy
Top achievements
Rank 1
answered on 23 Apr 2013, 01:28 PM
Hi princy Is it possible to display an alert?
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Apr 2013, 01:36 PM
Hi,

If you want to display an alert, you can attach the OnDateSelected client event to the second RadMonthYearPicker and try the following JavaScript.

JavaScript:
<script type="text/javascript">
    function OnDateSelected(sender, args) {
        var Month1 = $find('<%=RadMonthYearPicker1.ClientID %>');
        var date1 = Month1.get_dateInput().get_selectedDate().getMonth();
        var date2 = sender.get_dateInput().get_selectedDate().getMonth();
        if (date2 < date1) {
            alert("The second date must be after the first one");
            sender.clear();
        }
    }
</script>

Thanks,
Princy.
Tags
Calendar
Asked by
Ivy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ivy
Top achievements
Rank 1
Share this question
or