Putting today’s date on the form using javascript

Use the following code to put the date in the form.

<input type="text" id="todaydate" size="15" ></font></p>
 <script type="text/javascript" >
  var today = new Date();
 var dd = today.getDate();
 var mm = today.getMonth()+1; //January is 0!
 var yyyy = today.getFullYear();
if(dd<10) {
if(mm<10) {
 today = yyyy+'-'+mm+'-'+dd;
 var element = document.getElementById("todaydate");
 element.value = today;



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s