// Log-In
 /// <summary>
 /// Gets an email address form item for use on log-in pages. The validation sets this data value to the post back value of the text box, if valid, or adds
 /// the specified error message to the form item.
 /// </summary>
 public static FormItem<EwfTextBox> GetEmailAddressFormItem( this DataValue<string> emailAddress, FormItemLabel label, string errorMessage, ValidationList vl )
 {
     return FormItem.Create(
         label,
         new EwfTextBox( "" ),
         validationGetter:
             control =>
             new EwfValidation(
                 ( pbv, validator ) =>
                 emailAddress.Value =
                 validator.GetEmailAddress( new ValidationErrorHandler( ( v, ec ) => v.NoteErrorAndAddMessage( errorMessage ) ), control.GetPostBackValue( pbv ), false ),
                 vl ) );
 }
        // Adding a New User

        /// <summary>
        /// Gets password and "password again" form items. The validation sets this data value to the provided password, and ensures that the two form items contain
        /// identical, valid passwords.
        /// </summary>
        public static IReadOnlyCollection <FormItem> GetPasswordModificationFormItems(
            this DataValue <string> password, Unit?textBoxWidth = null, FormItemLabel firstLabel = null, FormItemLabel secondLabel = null)
        {
            var passwordAgain         = new DataValue <string>();
            var passwordAgainFormItem = FormItem.Create(
                secondLabel ?? "Password again",
                new EwfTextBox("", masksCharacters: true, disableBrowserAutoComplete: true),
                validationGetter: control => new EwfValidation((pbv, v) => passwordAgain.Value = control.GetPostBackValue(pbv)));

            if (textBoxWidth.HasValue)
            {
                passwordAgainFormItem.Control.Width = textBoxWidth.Value;
            }

            var passwordFormItem = FormItem.Create(
                firstLabel ?? "Password",
                new EwfTextBox("", masksCharacters: true, disableBrowserAutoComplete: true),
                validationGetter: control => new EwfValidation(
                    (pbv, v) => {
                password.Value = control.GetPostBackValue(pbv);
                if (password.Value != passwordAgain.Value)
                {
                    v.NoteErrorAndAddMessage("Passwords do not match.");
                }
                else
                {
                    var strictProvider = SystemProvider as StrictFormsAuthUserManagementProvider;
                    if (strictProvider != null)
                    {
                        strictProvider.ValidatePassword(v, password.Value);
                    }
                    else if (password.Value.Length < 7)
                    {
                        v.NoteErrorAndAddMessage("Passwords must be at least 7 characters long.");
                    }
                }
            }));

            if (textBoxWidth.HasValue)
            {
                passwordFormItem.Control.Width = textBoxWidth.Value;
            }

            return(new[] { passwordFormItem, passwordAgainFormItem });
        }
        // Log-In

        /// <summary>
        /// Gets an email address form item for use on log-in pages. The validation sets this data value to the post back value of the text box, if valid, or adds
        /// the specified error message to the form item.
        /// </summary>
        public static FormItem <EwfTextBox> GetEmailAddressFormItem(this DataValue <string> emailAddress, FormItemLabel label, string errorMessage, ValidationList vl)
        {
            return(FormItem.Create(
                       label,
                       new EwfTextBox(""),
                       validationGetter:
                       control =>
                       new EwfValidation(
                           (pbv, validator) =>
                           emailAddress.Value =
                               validator.GetEmailAddress(new ValidationErrorHandler((v, ec) => v.NoteErrorAndAddMessage(errorMessage)), control.GetPostBackValue(pbv), false),
                           vl)));
        }