Many components support user input validation with parameters that control the validation itself and the formatting on the control should validation fail. The configuration for validation is standard for all components.

In the following example, the input is expected to be a valid email address and is also required. Calling validate on the component instance will run the validation and return a boolean specifying whether it was successful. If not successful, the CSS class is-invalid will be added to the input.

const email = new wire.bsInput().render("#email", {
    validate: { type: "email", required: true, css: "is-invalid" }


const valid = email.validate();

Component validations use the wire.ui.validate method. For details on validation including other validation types and formatting options, visit the wire.ui.validate documentation.

Last updated