Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1635 Can I prefill a text form field with the current date?

irt.org | Knowledge Base | JavaScript | Date | Q1635 [ previous next ]

Q1635 Can I prefill a text form field with the current date?

Try:

<html>
<head>
<script language="JavaScript"><!--
function makeDate() {
   now = new Date();
   return now.getYear() + '/' + (now.getMonth()+1) + now.getDate();
}
//--></script>
</head>
<body onLoad="document.myForm.myField.value = makeDate()">
<form name="myForm">
<input type="text" name="myField" value="">
</form>
</body>
</html>

Feedback on 'Q1635 Can I prefill a text form field with the current date?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.