I just started to use javascript since few days.
Actually I try do display an error if a date is inferior to an other date, so I’ve done the following function:
<script type="text/javascript">
function verif_prescription()
{
var date1= document.getElementById('date1').value;
var date2= document.getElementById('date3').value;
if(date1>date2)
{
alert('Vous ne pouvez pas avoir une date de prescription inferieure a la date d\'emission');
document.getElementById('enreg1').setAttribute('disabled','disabled');
}
else
{
document.getElementById('enreg1').removeAttribute('disabled')
}
}
</script>
But actualy it does not work for all dates for example if I have on date1= 23-04-2010 and on date3 = 22-04-2012 it display the error, but it should not. SO I think it does not compare the error, I’ve been looking for something to do like in php but I did not find anything.
Kind regards.
SP
http://jsfiddle.net/rd13/vnMUZ/
or:
Date.parse(“24-04-2012”); // Wouldn’t work unless you specify the format as being dd/mm/yyy, i.e. UK format.