Validate hour value - Node.js Date

Node.js examples for Date:Hour

Description

Validate hour value

Demo Code

Validator.validateHour = function(hour) {
    var exp = /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/;
    if (hour.match(exp)) {
        return true;
    } else {//from   w  w  w.  ja  v a2s .  com
        return false;
    }
};

Related Tutorials