Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show calendar on text box click in html

In html i want to show calendar to select date while clicking a text box. then we select a date from that calendar then the selected date will be display in that text box.

like image 923
Vinoth Avatar asked Feb 25 '13 06:02

Vinoth


People also ask

How do I add a calendar to a text box in HTML?

The <input type="date"> defines a date picker. The resulting value includes the year, month, and day. Tip: Always add the <label> tag for best accessibility practices!

How do you display the current date in a text field?

getMonth() + 1; var year = todaydate. getFullYear(); var datestring = day + "/" + month + "/" + year; document. getElementById("frmDate"). value = datestring; } getDate();


2 Answers

Starting with HTML5, <input type="date" /> will do just fine.

Demo: http://jsfiddle.net/8N6KH/

like image 95
Silviu Burcea Avatar answered Sep 18 '22 09:09

Silviu Burcea


You should read-up on jQueryUI Datepicker

Once you include the relevant jQuery UI library, it's as simple as,

Script:

$(function() {
    $( "#datepicker" ).datepicker();
});

HTML:

<input type="text" id="datepicker" />

Pros:

  • it is thoroughly tested for x-browser compatibility, so you won't have a problem.
  • Separate css file, so you can customize it as per your liking
like image 23
painotpi Avatar answered Sep 22 '22 09:09

painotpi