Loa said:
How do I create a form field that defaults to current date using
format mm/dd/yyyy?
Would also like to be able to change the date if necessary and would
like to have it validated to correct format mm/dd/yyyy
Any info will be greatly appreciated
Here is some code which puts today's date in a form fleld in format
mm/dd/yyyy
Changing the date and clicking on "Check" will give a rudimentary date
check.
It will either display the full UTC date or NaN.
It will throw out days or months without leading zeroes.
But it will also accept 01/32/2006 as 1 Feb 2006.
and 01/118/2006 as 11 Jan 2006 (but thows out 01/70/2006)
For better date checkers, see other posts here, especially those by Dr John
Stockton.
Or you could write one yourself.
Just code this into JavaScript

Thirty days hath September,
April June and November.
All the rest have thirty-one
Excepting February alone,
Which has twenty-eight days clear,
But twenty-nine each Leap Year.
<html>
<head>
<script type="text/javascript">
function showDate()
{
var now = new Date()
var month = now.getMonth()+1
var date = now.getDate()
month = (month < 10)? "0" + month : month
date = (date < 10)? "0" + date : date
document.form1.datefield.value = month + '/' + date + '/' +
now.getFullYear()
}
function calcDate()
{
var montharry = new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
with (document.form1)
{
var month = datefield.value.substr(0,2)
var day = datefield.value.substr(3,2)
var year = datefield.value.substr(6)
}
alert(new Date(day + montharry[month-1] + year ))
}
</script>
</head>
<body onload="showDate()">
<form name="form1" action="">
Date:
<input type="text" id="datefield" size="10" />
<input type="button" value="Check" onclick="calcDate()" />
</form>
</body>
</html>
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website:
http://trevorl.mvps.org/