Is valid postal code - Node.js Regular expression

Node.js examples for Regular expression:Validation

Description

Is valid postal code

Demo Code


var isValidPostalCode = function(str){
    var reg = new RegExp(/^[0-8]\d{5}(?!\d)$/);
    if(typeof str === 'string') return reg.test(str);
    return reg.test(str.toString());
};

Related Tutorials