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

DatePicker onError Blur

3 Answers 126 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Adam Lindsay
Top achievements
Rank 1
Adam Lindsay asked on 09 Dec 2009, 04:20 AM
Very simple:  I want to display an alert onError with a datepicker but, I don't want the alert to display when they leave the field.  Currently, the onError event fires for invalid dates when the user leaves the field.  I either need to supress that event during that case or make the onError method smart enough to know if it is called during a Blur of the field.

Thoughts?

- Adam

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Dec 2009, 06:46 AM
Hello Adam,

I guess you want to show the invalid message alert when clicking the submit button instead of user leaves the textfield. If so you can use CustomValidator control in order to achieve this instead of attaching OnError event.

client-side code:
 
<script type="text/javascript"
    // ClientValidationFunction of CustomValidator 
    function ClientValidationFunction1(sender, args) { 
        var datepicker = $find("<%=RadDatePicker1.ClientID%>"); 
        if (datepicker.get_dateInput()._invalid) { 
            alert("Invalid"); 
            args.IsValid = false
        } 
    }   
</script> 

-Shinu.
0
Adam Lindsay
Top achievements
Rank 1
answered on 09 Dec 2009, 02:56 PM
That is exactly what I want to do.  I have javascript tied to a button that validates the date. I attempted to use datepicker.get_dateInput()._invalid to determine if the date was valid but it always returns false (regardless of what I put in the datapicker).  I think this has something to do with the fact that everything on the page is in an AjaxPanel.

I will attempt the custom validator but, is there any way to simply make the javascript call (in an ajaxified page) to determine if the date is valid without validators.

Thanks again.
0
Pavlina
Telerik team
answered on 14 Dec 2009, 01:49 PM
Hello Adam,

The ajaxRequestWithTarget(eventTarget, eventArgument) function can be called to simulate a postback/AJAX request send by other control (besides AjaxManager or AjaxPanel) with the specified UniqueID and specified arguments.

More information is available here:
http://www.telerik.com/help/aspnet-ajax/ajxclientsideapi.html

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Calendar
Asked by
Adam Lindsay
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Adam Lindsay
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or