hi all
i want to use a function to format date in (yyyy/mm/dd).
The function is in my below code. how can i call this function onChange or onBlur so that when the user enters date it should alert if the date format is not valid.
Code:<html> <head> <script language="javascript"> function validDate(y,m,d) { if (y != parseInt(y,10) || m != parseInt(m,10) || d != parseInt(d,10)) return false; m--; var nd = new Date(y, m, d); if (y == nd.getFullYear() && m == nd.getMonth() && d == nd.getDate()) return nd; else return false; } var customer_dob = validDate(year, month, day); if (!customer_dob) { alert('the date entered is invalid'); } </script> </head> <body> <form action="" method="get" name="advertise"> <input type="text" name="customer_dob" onChange="return validDate();" /> </form> </body>



Reply With Quote


Bookmarks