	MaxLengthValidator.prototype = new ValidatorDecorator();

	MaxLengthValidator.constructor = MaxLengthValidator;
    MaxLengthValidator.baseConstructor = ValidatorDecorator;
	MaxLengthValidator.superclass = ValidatorDecorator.prototype;


	function MaxLengthValidator(validatorObject, errMsg, maxLength) {
		if(arguments.length > 0)
		{
			MaxLengthValidator.baseConstructor.call(this, errMsg, validatorObject);
            this.maxLength = maxLength;
		}
	}

	MaxLengthValidator.prototype.isValid = function(id) {
            // console.log("BEGIN: MaxLengthValidator.isValid()");
			var maxInput = document.getElementById(id);
            var isValid = null;
            var inputValue = Trim(maxInput.value);

            
            // It is not the job of the MaxLengthValidator to
            // check if the input field is not blank,
            // That is the job of the NotBlankValidator
            // or alternately the BlankOkValidator.
            if(inputValue.length == 0)
            {
                //console.log("The length of the field is zero ignoring");
                isValid = true;
            }
            else
            {
                isValid = (inputValue.length <= this.maxLength);
                // console.log("length: " + inputValue.length);
                // console.log("maxLength: " + this.maxLength);
                // console.log("isValid: " + isValid);
            }

            // console.log("END: MaxLengthValidator.isValid()");
			return isValid;
	};