JavaScript Comprobar fecha

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript Comprobar fecha相关的知识,希望对你有一定的参考价值。

/**--------------------------
//* 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;
}

以上是关于JavaScript Comprobar fecha的主要内容,如果未能解决你的问题,请参考以下文章

javascript Comprobar sin uncheckboxestáseleccionadocon jQuery

JavaScript Comprobar si un combotienealgúnvalorseleccionado

JavaScript Comprobar si un valor esunnúmeroentero

text 检查电子邮件correcto comprobar

java comprobar复选框列表框

csharp comprobar饼干