examples/chatty/public/js/app.js
function validateNum() {
        var pass = true,
        num = '';

        ['#areacode', '#phnum1', '#phnum2'].forEach(function(id) {
            var $e = $(id),
            val = $e.val();

            if(!val || val.length !== parseInt($e.attr('maxlength'), 10)) {
                pass = false;
                $e.addClass('error');
            }
            else
                num += val;
        });

        if(!pass) return false;

        return num;
    }
function validateNum() {
        var pass = true,
        num = '';

        ['#areacode', '#phnum1', '#phnum2'].forEach(function(id) {
            var $e = $(id),
            val = $e.val();

            if(!val || val.length !== parseInt($e.attr('maxlength'), 10)) {
                pass = false;
                $e.addClass('error');
            }
            else
                num += val;
        });

        if(!pass) return false;

        return num;
    }
function validateNum ( ) { var pass = true , num = '' ; [ '#areacode' , '#phnum1' , '#phnum2' ] . forEach ( function ( id ) { var $e = $ ( id ) , val = $e . val ( ) ; if ( ! val || val . length !== parseInt ( $e . attr ( 'maxlength' ) , 10 ) ) { pass = false ; $e . addClass ( 'error' ) ; } else num += val ; } ) ; if ( ! pass ) return false ; return num ; }
validate the phone number fields
validate the phone number fields