/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/**-------------------------- //* Validate Date Field script- By JavaScriptKit.com //* For this script and 100s more, visit http://www.javascriptkit.com //* This notice must stay intact for usage ---------------------------**/ /* * Retocado por Sendoa Portuondo para un funcionamiento más personalizado */ function checkdate(dia, mes, anio){ var validformat = /^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity var returnval = false; if(!validformat.test(input.value)){ return false; }else{ //Detailed check for valid date ranges var monthfield = mes; var dayfield = dia; var yearfield = anio; var dayobj = new Date(yearfield, monthfield-1, dayfield); if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){ return false; }else{ return true; } } return true; }