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

[Solved] RadDatePicker ClientValidationFunction fires twice

1 Answer 107 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Gaurav
Top achievements
Rank 1
Gaurav asked on 13 May 2009, 11:40 AM
Hi,

I used  RadCalendar.NET2 ( Version: 2.2.1.0, Runtime Version: v2.0.50727)

I am using RadDatpicker Inside RadGrid.
I used CustomValidator to validate Date entered(typed into built in date inputbox) /selected(from calendar).

We have situation here:

When user changes date using Shared Calendar:

When user selects date using shared Calendar and if selected date does not belongs to validate range than associate ClientValidationFunction fire properly (e.g only once as it should be). Everything works fine.

When user  changes date by typing into built-in Date input box:

When user changes date by typing into built-in date input box of Rad Date picker and if date does not belongs to validate date range, ClientValidationFunction fires twice. This create the problem. It should fire once only.

BTW:  here is design code and javascript function that I used to validate entered/selected date.

<Design>

 <EditItemTemplate>
                                                                                            <radCln:RadDatePicker ID="rdTransactionDate" runat="server" Width="110px" MinDate="1960/1/1"
                                                                                                MaxDate="2099/1/1" Calendar-Skin="Default2006" UseEmbeddedScripts="false">
                                                                                            </radCln:RadDatePicker>
                                                                                            <asp:CustomValidator ID="cvTransactionDate" runat="server" ClientValidationFunction="CheckDate"
                                                                                                ControlToValidate="rdTransactionDate" SetFocusOnError ="true" ></asp:CustomValidator>
                                                                                        </EditItemTemplate>
</Design>

<script language="javascript">
function CheckDate(source, arguments)
    {
        try
        {
            var ControlName = source.id;
            var objDate = document.getElementById(ControlName.replace('cvTransactionDate','rdTransactionDate')).value;
            
            var objYear = document.getElementById('ctl00_CntAdminBody_cmbyear');
            var objCurYear = parseInt(objYear.value);
            
            var objMinYear = objCurYear - 1;
            var objMinDate = objMinYear + '-07-01';
            var objMaxDate = objCurYear + '-06-30';
            
            arguments.IsValid = true;
            
            if(objDate < objMinDate || objDate > objMaxDate)
            {
                alert("Enter Date Between FinancialYear");
                arguments.IsValid = false;
            }
            
        }
        catch(e)
        {
        }
       
    }



</script>

Please let me know what might be wrong here and also if there is any solution.

Best Regards,
Gaurav

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 18 May 2009, 01:24 PM
Hello Gaurav,

I was able to replicate the described behavior and will forward the issue to our developers.

However, I suggest that you migrate to RadCalendar for ASP.NET AJAX where this issue is solved.

I hope this helps.

All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or