TagBoxValidateBy Enum

Lists values that define how a TagBox located within the standard EditForm is validated.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.dll

Declaration

public enum TagBoxValidateBy

Members

Name Description
Tags

The editor's tags are validated.

SelectedItems

The drop-down list’s selected items are validated.

Remarks

Use the TagBoxValidateBy enumeration values to set the DxTagBox.ValidateBy property.

The DevExpress UI components support the Blazor's form validation. For more information, refer to the ASP.NET Core Blazor forms and validation MSDN article.

The code below uses the ValidateBy property to validate email addresses (custom tags) specified in the TagBox. In this example the following validation settings are specified:

After a user types an email address, the TagBox is outlined in red or green depending on the validation result.

<EditForm Model="@recipients" OnValidSubmit="@HandleValidSubmit" OnInvalidSubmit="@HandleInvalidSubmit">
    <DataAnnotationsValidator />
    <p>
        <label for="emails">Recipients:</label>
        <DxTagBox Id="emails"
                  NullText="Select email recipients"
                  Data="@Emails.DataSource"
                  AllowCustomTags="true"
                  ValidateBy="@TagBoxValidateBy.Tags"
                  @bind-Tags="@recipients.Data"
                  @bind-DropDownVisible="@DropDownVisible">
        </DxTagBox>
        <ValidationMessage For="@(() => recipients.Data)" />
    </p>
    <button type="submit">Submit</button>
</EditForm>

@code {
    EmailRecipients recipients = new EmailRecipients();

    private void HandleValidSubmit() {
        Console.WriteLine("OnValidSubmit");
    }
    private void HandleInvalidSubmit() {
        Console.WriteLine("OnInvalidSubmit");
    }
} 

blazor_TagBox_Validation

NOTE

Online Demo: TagBox - Validation

See Also