I have the below form with javascript to calculate a hidden password based on the current year and day of the year. ie. 2006026 minus a 6 digit number = the hidden password
All I want to do is enter the 6 digit number and then calculate. Currently I have to enter the current date and the 6 digit number.. Is there a way to store the current date in the required format mm/dd/yyyy to a variable?
<html>
<head>
<script>
function Calculate()
{
today=new Date()
var EnteredMonth = MyForm.Date1.value.substr(0,2) - 1;
var EnteredDay = MyForm.Date1.value.substr(3,2);
var EnteredYear = MyForm.Date1.value.substr(6,4);
var EnteredDate = new Date(EnteredYear, EnteredMonth, EnteredDay, 0, 0, 0);
var EnteredSN = MyForm.SN.value;
today=new Date()
var startofyear=new Date(EnteredDate.getFullYear(), 0, 1)
var one_day=1000*60*60*24
var DayOfYear = Math.ceil((EnteredDate.getTime() - startofyear.getTime()) / one_day) + 1
var Calc = ((EnteredYear + "0") + DayOfYear)
var HiddPass = Calc - EnteredSN
MyForm.Pass.value = HiddPass;
}
</script>
<title>Untitled Document</title>
</head>
<body>
<font size="2" face="Arial">(Dates must be entered as mm/dd/yyyy i.e. 01/02/2003)<br>
</font>
<form name="MyForm">
<font face="Arial"><font size="2">Todays Date </font>
<input type="text" name="Date1" Value="" size="10">
<font size="2"> Last 6 digits
of number </font><Input type="text" name="SN" Size="6"><font size="2">
<br>
<br>
</font><input type="button" name="calc" value="Calculate" onClick="Calculate()"><font size="2">
</font>
<input type="reset" name="Reset" value="Clear"><font size="2">
Hidden Password is </font><Input type="text" name="Pass" Size="7"><font size="2">
<br>
<br>
</font></font>
<br>
</form>
</body>
</html>
All I want to do is enter the 6 digit number and then calculate. Currently I have to enter the current date and the 6 digit number.. Is there a way to store the current date in the required format mm/dd/yyyy to a variable?
<html>
<head>
<script>
function Calculate()
{
today=new Date()
var EnteredMonth = MyForm.Date1.value.substr(0,2) - 1;
var EnteredDay = MyForm.Date1.value.substr(3,2);
var EnteredYear = MyForm.Date1.value.substr(6,4);
var EnteredDate = new Date(EnteredYear, EnteredMonth, EnteredDay, 0, 0, 0);
var EnteredSN = MyForm.SN.value;
today=new Date()
var startofyear=new Date(EnteredDate.getFullYear(), 0, 1)
var one_day=1000*60*60*24
var DayOfYear = Math.ceil((EnteredDate.getTime() - startofyear.getTime()) / one_day) + 1
var Calc = ((EnteredYear + "0") + DayOfYear)
var HiddPass = Calc - EnteredSN
MyForm.Pass.value = HiddPass;
}
</script>
<title>Untitled Document</title>
</head>
<body>
<font size="2" face="Arial">(Dates must be entered as mm/dd/yyyy i.e. 01/02/2003)<br>
</font>
<form name="MyForm">
<font face="Arial"><font size="2">Todays Date </font>
<input type="text" name="Date1" Value="" size="10">
<font size="2"> Last 6 digits
of number </font><Input type="text" name="SN" Size="6"><font size="2">
<br>
<br>
</font><input type="button" name="calc" value="Calculate" onClick="Calculate()"><font size="2">
</font>
<input type="reset" name="Reset" value="Clear"><font size="2">
Hidden Password is </font><Input type="text" name="Pass" Size="7"><font size="2">
<br>
<br>
</font></font>
<br>
</form>
</body>
</html>