Hi, I am trying to validate 2 date fields one which is the from date and the other which is a to date. I need to add validation to check that is the return date is greater than the start date then tell the user. I have done this and thought it was working but say i put 28/01/2008 for the first field and put 02/02/2008 for the second it tells the user that the return date is greater than the start date. It seems that it must only be taking the first number and not taking into consideration the date. Here is the code: function checkform ( form ) { if (form.arrivaldate.value > form.returndate.value) { alert( "Please enter a return date greater than your arrival date." ); form.returndate.focus(); return false ; } // ** END ** return true ; } Code (markup): Any ideas? Cheers, Adam
try looking at this http://www.w3schools.com/js/js_obj_date.asp what you need is a date object to compare, at the moment you are comparing a string
So do you mean i need to change the input to something like 2008.03.14 in place of 28/01/2008. If i did this what would i change the validation JavaScript to?