Results 1 to 2 of 2

Thread: Add current date to web form using Javascript

  1. #1
    Join Date
    Aug 2013

    Add current date to web form using Javascript

    I have the following form that needs to have the date inserted using Javascript.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    		<style type="text/css">
    			.myForm td, input {
    				font-family: tahoma;
    				font-size: 12px;
    			.required {
    				color: red;
    		<form method="post" action="%%FORMACTION%%">
    			<table border="0" class="myForm" cellpadding="2">
    	<td><span class="required">*</span>&nbsp;
    Your Email Address:</td>
    	<td><input type="text" name="email" value="%%Email%%" /></td>
    <input type="hidden" id="CustomFields_30_dd" name="CustomFields[30][dd]" value="26"%%CustomField_30_01_dd%% />
    <input type="hidden" id="CustomFields_30_mm" name="CustomFields[30][mm]" value="08"%%CustomField_30_01_mm%% />
    <input type="hidden" id="CustomFields_30_yy" name="CustomFields[30][yy]" value="2013"%%CustomField_30_2008_yy%% />
    <input type="hidden" id="lists_3" name="lists[]" value="3"%%Lists_3%% />
    <input type="hidden" id="lists_8" name="lists[]" value="8"%%Lists_8%% />
    						<input type="submit" value="Update your details" />
    value="26" needs to be replaced with the current day.
    value="08" needs to be replaced with the current month.
    value="2013" needs to be replaced with the current year.

    Thanks in advance for your help.

  2. #2
    Join Date
    Nov 2006
    You can add Javascript code at the bottom of your form:
    <script type="text/javascript">
    var today=new Date();

    Remember to always give your web form an ID and/or a name.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles