Validate Hex value using regex - Node.js Regular expression

Node.js examples for Regular expression:Validation

Description

Validate Hex value using regex

Demo Code


Validator.validateHexvalue = function(hexValue) {
    var exp = /^#?([a-f0-9]{6}|[a-f0-9]{3})$/;
    if (hexValue.match(exp)) {
        return true;
    } else {/*from  w w  w  . j ava2 s .c  o m*/
        return false;
    }
};

Related Tutorials