DatePicker onError Blur

4 posts, 0 answers
  1. Adam Lindsay
    Adam Lindsay avatar
    21 posts
    Member since:
    Oct 2009

    Posted 08 Dec 2009 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Dec 2009 Link to this post

    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.
  3. Adam Lindsay
    Adam Lindsay avatar
    21 posts
    Member since:
    Oct 2009

    Posted 09 Dec 2009 Link to this post

    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.
  4. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 14 Dec 2009 Link to this post

    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.
Back to Top