How to assign a date value from a calendar popup to a hidden field

Posted on 2008-11-12
Last Modified: 2013-11-27
I have a search form with a couple of textboxes, dropdownlist controls and a Ajax calendar control. What I would like to do is to show, when picked a date from the calendar, this date in a label control in a ddd, MMM dd, yyyy format. Further I have a range validator to check if the picked date is in the future. If okay submit search form. My question is: can I store the picked date in a hidden field in short date format and manipulate this date to the above format and put this in a label control? I would like to use the hidden field value to query data when submitting the search from. I hope someone out there can help me how to tackle this. Many thanks in advance.

Question by:PdeLorme
    LVL 6

    Expert Comment

    Which datepicker are you using? mootools? jquery? .... ?

    Author Comment

    AJAX calendarextender control.
    LVL 3

    Accepted Solution

    I don't know CalendarExtender, but, according to this page

    to get the current selected date, you should add OnClientDateSelectionChanged="updateHiddenField" attribute to your CalendarExtender control, place a hidden input in the form (e.g. <input type="hidden" id="myHiddenInput" />) and declare a javascript function:

    function updateHiddenField(sender,args)
        document.getElementById("myHiddenInput").value = sender._selectedDate;

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Android App Development

    This course will involve creating widgets, customize list view, grid view, spinners, etc. Creating applications using audio, video, and SQLite database. Ending with publication on Google Play.

    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now