Meteor.methods({
    checkHKID: function (hkid) {
        if (hkid.length > 9){throw new Meteor.Error('invalid', 'The HKID entered is invalid')} else {
        if (hkid.length < 8){throw new Meteor.Error('invalid', 'The HKID entered is invalid')} else {
        var hkidPat = /^([A-Z]{1,2})([0-9]{6})([A0-9])$/;
        var matchArray = hkid.match(hkidPat);
        if(matchArray == null){throw new Meteor.Error('invalid', 'The HKID entered is invalid')} else {
            var checkSum = 0;
            var charPart = matchArray[1];
            var numPart = matchArray[2];
            var checkDigit = matchArray[3];
            if (charPart.length == 2) {
                checkSum += 9 * (charPart.charAt(0).charCodeAt(0) - 55);
                checkSum += 8 * (charPart.charAt(1).charCodeAt(0) - 55);
            } else {
                checkSum += 8 * (charPart.charCodeAt(0)-55);
                checkSum += 324;
            }
            for (var i = 0, j = 7; i < numPart.length; i++, j--){
                checkSum += j * numPart.charAt(i);
            }

            var remaining = checkSum % 11;
            var checkNumber = 11 - remaining;
            if(checkDigit == checkNumber) {} else {throw new Meteor.Error('invalid', 'The HKID entered is invalid')}
        return(hkid)
    }}}}

});
Meteor.methods({
    checkHKID: function (hkid) {
        var hkidPat = /^([A-Z]{1,2})([0-9]{6})([A0-9])$/;
        var matchArray = hkid.match(hkidPat);
        if(matchArray == null){throw new Meteor.Error('invalid', 'The HKID entered is invalid')} else {
            var checkSum = 0;
            var charPart = matchArray[1];
            var numPart = matchArray[2];
            var checkDigit = matchArray[3];
            if (charPart.length == 2) {
                checkSum += 9 * (charPart.charAt(0).charCodeAt(0) - 55);
                checkSum += 8 * (charPart.charAt(1).charCodeAt(0) - 55);
            } else {
                checkSum += 8 * (charPart.charCodeAt(0)-55);
                checkSum += 324;
            }
            for (var i = 0, j = 7; i < numPart.length; i++, j--){
                checkSum += j * numPart.charAt(i);
            }

            var remaining = checkSum % 11;
            var checkNumber = 11 - remaining;
            if(checkDigit == checkNumber) {} else {throw new Meteor.Error('invalid', 'The HKID entered is invalid')}
        return(hkid)
    }}

});
Remove redundant length check