Hello all, hope you are well.
I have a script that allows users to select a date from three drop down lists.
What I want to do now is check to make sure the date selected is not before the current date.
I imagine I have to use the “new Date” function to compare however I am having trouble with it! Can any one point me in the right direction with this code or suggest a new method if this one is doomed! lol
[CODE]document.forms.order.os4.value
the above code points to the field where the date selected is stored and is in the format yyyy-mm-dd. I used the replace function to convert it to yyyy,mm,dd for the new Date function.
[CODE]<SCRIPT language=javascript type=text/javascript>
function validateForm()
{
var x=(document.forms.order.os4.value);
var y=x.replace(/-/g, “,”);
var z=new Date(y);
var today = new Date();
if (z<today)
{
alert(“Date selected is before today!”);
return false;
}
else
{
return true;
}
}
</SCRIPT>
Thanks very much in advance for any input, it is much appreciated.
Kind regards, Mike