Example #1
0
        protected override bool OnServerSideEvaluate()
        {
            string value = GetControlValidationValue(ControlToValidate);

            if (String.IsNullOrEmpty(value))
            {
                if (IgnoreEmptyValue)
                {
                    return(true);
                }
                else
                {
                    Text = "This field is required";
                    return(false);
                }
            }

            DateTime result;

            if (!InputDateParser.TryParse(value, out result))
            {
                Text = string.Format("{0} is not a valid date for '{1}' format.", value, InputDateParser.DateFormat);
                return(false);
            }

            return(true);
        }
Example #2
0
        protected override bool OnServerSideEvaluate()
        {
            string value = GetControlValidationValue(ControlToValidate);

            if (String.IsNullOrEmpty(value))
            {
                if (IgnoreEmptyValue)
                {
                    return(true);
                }
                else
                {
                    Text = ValidationErrors.ThisFieldIsRequired;
                    return(false);
                }
            }

            DateTime result;

            if (!InputDateParser.TryParse(value, out result))
            {
                return(false);
            }

            return(true);
        }