Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Date | Q1635 [ previous next ]

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?'

©2018 Martin Webb