/// <summary>
    /// Returns true if user control is valid.
    /// </summary>
    public override bool IsValid()
    {
        var postedFile = uploader.PostedFile;

        // Check allow empty
        if ((FieldInfo != null) && !FieldInfo.AllowEmpty && ((Form == null) || Form.CheckFieldEmptiness))
        {
            if (String.IsNullOrEmpty(uploader.CurrentFileName) && (postedFile == null))
            {
                // Empty error
                if ((ErrorMessage != null) && !ErrorMessage.EqualsCSafe(ResHelper.GetString("BasicForm.InvalidInput"), true))
                {
                    ValidationError = ErrorMessage;
                }
                else
                {
                    ValidationError += ResHelper.GetString("BasicForm.ErrorEmptyValue");
                }
                return(false);
            }
        }

        if ((postedFile != null) && (!String.IsNullOrEmpty(postedFile.FileName.Trim())))
        {
            // Test if file has allowed file-type
            string customExtension = ValidationHelper.GetString(GetValue("extensions"), String.Empty);
            string extensions      = null;

            if (CMSString.Compare(customExtension, "custom", true) == 0)
            {
                extensions = ValidationHelper.GetString(GetValue("allowed_extensions"), String.Empty);
            }

            // Only extensions that are also allowed in settings can be uploaded
            extensions = UploadHelper.RestrictExtensions(extensions, SiteContext.CurrentSiteName);

            string ext             = Path.GetExtension(postedFile.FileName);
            string validationError = string.Empty;

            if (extensions.EqualsCSafe(UploadHelper.NO_ALLOWED_EXTENSION))
            {
                validationError = ResHelper.GetString("uploader.noextensionallowed");
            }
            else if (!UploadHelper.IsExtensionAllowed(ext, extensions))
            {
                validationError = string.Format(ResHelper.GetString("BasicForm.ErrorWrongFileType"), HTMLHelper.HTMLEncode(ext.TrimStart('.')), extensions.Replace(";", ", "));
            }

            if (!string.IsNullOrEmpty(validationError))
            {
                ValidationError += validationError;
                return(false);
            }
        }

        return(true);
    }
    /// <summary>
    /// Returns true if user control is valid.
    /// </summary>
    public override bool IsValid()
    {
        // Check value
        string strValueFrom   = dtmTimeFrom.DateTimeTextBox.Text.Trim();
        string strValueTo     = dtmTimeTo.DateTimeTextBox.Text.Trim();
        bool   required       = (FieldInfo != null) && !FieldInfo.AllowEmpty;
        bool   checkEmptiness = (Form == null) || Form.CheckFieldEmptiness;

        if (required && checkEmptiness && (String.IsNullOrEmpty(strValueFrom) && String.IsNullOrEmpty(strValueTo)))
        {
            // Empty error
            if ((ErrorMessage != null) && !ErrorMessage.EqualsCSafe(ResHelper.GetString("BasicForm.InvalidInput"), true))
            {
                ValidationError = ErrorMessage;
            }
            else
            {
                ValidationError += ResHelper.GetString("BasicForm.ErrorEmptyValue");
            }
            return(false);
        }

        bool checkForEmptiness = (required && checkEmptiness) || (!String.IsNullOrEmpty(strValueTo) && !String.IsNullOrEmpty(strValueFrom));

        if (checkForEmptiness)
        {
            if (!ValidationHelper.IsDateTime(strValueTo) || !ValidationHelper.IsDateTime(strValueFrom))
            {
                if (dtmTimeFrom.EditTime)
                {
                    // Error invalid DateTime
                    ValidationError += String.Format("{0} {1}.", ResHelper.GetString("BasicForm.ErrorInvalidDateTime"), DateTime.Now);
                }
                else
                {
                    // Error invalid date
                    ValidationError += String.Format("{0} {1}.", ResHelper.GetString("BasicForm.ErrorInvalidDate"), DateTime.Today.ToString("d"));
                }

                return(false);
            }
        }

        if (!dtmTimeFrom.IsValidRange() || !dtmTimeTo.IsValidRange())
        {
            ValidationError += GetString("general.errorinvaliddatetimerange");
            return(false);
        }

        return(true);
    }
    /// <summary>
    /// Returns true if user control is valid.
    /// </summary>
    public override bool IsValid()
    {
        // Check value
        string strValue       = timePicker.DateTimeTextBox.Text.Trim();
        bool   required       = (FieldInfo != null) && !FieldInfo.AllowEmpty;
        bool   checkEmptiness = (Form == null) || Form.CheckFieldEmptiness;

        if (required && String.IsNullOrEmpty(strValue) && checkEmptiness)
        {
            // Empty error
            if ((ErrorMessage != null) && !ErrorMessage.EqualsCSafe(ResHelper.GetString("BasicForm.InvalidInput"), true))
            {
                ValidationError = ErrorMessage;
            }
            else
            {
                ValidationError += ResHelper.GetString("BasicForm.ErrorEmptyValue");
            }
            return(false);
        }

        if (AllowMacros && (MacroProcessor.ContainsMacro(strValue) || DateTimeHelper.IsNowOrToday(strValue)))
        {
            return(true);
        }

        if (((required && checkEmptiness) || !String.IsNullOrEmpty(strValue)) && (ValidationHelper.GetDateTime(strValue, DateTimeHelper.ZERO_TIME) == DateTimeHelper.ZERO_TIME))
        {
            if (timePicker.EditTime)
            {
                // Error invalid DateTime
                ValidationError += String.Format("{0} {1}.", ResHelper.GetString("BasicForm.ErrorInvalidDateTime"), DateTime.Now);
            }
            else
            {
                // Error invalid date
                ValidationError += String.Format("{0} {1}.", ResHelper.GetString("BasicForm.ErrorInvalidDate"), DateTime.Today.ToString("d"));
            }

            return(false);
        }

        if (CheckRange && !timePicker.IsValidRange())
        {
            ValidationError += GetString("general.errorinvaliddatetimerange");
            return(false);
        }

        return(true);
    }
 /// <summary>
 /// Returns true if user control is valid.
 /// </summary>
 public override bool IsValid()
 {
     // Check empty field
     if ((FieldInfo != null) && !FieldInfo.AllowEmpty && ((Form == null) || Form.CheckFieldEmptiness))
     {
         string value = ValidationHelper.GetString(directUpload.Value, string.Empty).Trim();
         if ((String.IsNullOrEmpty(value)) || (ValidationHelper.GetGuid(value, Guid.Empty) == Guid.Empty))
         {
             // Empty error
             if ((ErrorMessage != null) && !ErrorMessage.EqualsCSafe(ResHelper.GetString("BasicForm.InvalidInput"), true))
             {
                 ValidationError = ErrorMessage;
             }
             else
             {
                 ValidationError += ResHelper.GetString("BasicForm.ErrorEmptyValue");
             }
             return(false);
         }
     }
     return(true);
 }