Esempio n. 1
0
        public static bool ValidateInput(TextBox widget, string parentEditRecord, InputTypeValidator typeVal, bool validate)
        {
            if (!WidgetWithValidPropertyUtils.ValidateWidget(widget))
            {
                return(true);
            }

            widget.TypedValue = widget.Text;

            //don't validate what's not on my parent edit record
            if (!ProceedWithValidation(widget, parentEditRecord))
            {
                validate = false;
            }

            //don't keep values, always reset to true
            if (validate)
            {
                widget.Valid             = true;
                widget.ValidationMessage = "";
            }

            bool   valid             = true;
            string validationMessage = "";

            //if not validating, assume "" is valid, so skip mandatory validations
            if (validate)
            {
                valid = !widget.Mandatory || widget.TypedValue != "";
            }

            if (!valid)
            {
                validationMessage = widget.MandatoryValidationMessage;
            }
            else
            {
                valid = (widget.TypedValue == "") || typeVal(widget.TypedValue);
                if (!valid)
                {
                    validationMessage = widget.TypeValidationMessage;
                }
            }

            //if not validating, don't change the runtime properties
            if (validate)
            {
                widget.Valid             = valid;
                widget.ValidationMessage = validationMessage;
            }

            return(valid);
        }
Esempio n. 2
0
        public static bool ValidateComboBox(DropDownList widget, string parentEditRecord, bool validate)
        {
            if (!WidgetWithValidPropertyUtils.ValidateWidget(widget))
            {
                return(true);
            }

            //don't validate what's not on my parent edit record
            if (!ProceedWithValidation(widget, parentEditRecord))
            {
                validate = false;
            }

            //don't keep values, always reset to true
            if (validate)
            {
                widget.Valid             = true;
                widget.ValidationMessage = "";
            }

            bool   valid             = true;
            string validationMessage = "";

            //if not validating, assume "" is valid, so skip mandatory validations
            if (validate)
            {
                valid = !widget.Mandatory || !widget.SelectedValue.StartsWith(Constants.ComboBoxSpecialListIdPrefix);
            }

            if (!valid)
            {
                validationMessage = widget.MandatoryValidationMessage;
            }

            //if not validating, don't change the runtime properties
            if (validate)
            {
                widget.Valid             = valid;
                widget.ValidationMessage = validationMessage;
            }

            return(valid);
        }