Validation
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.
1
const email = new wire.bsInput().render("#email", {
2
...
3
validate: { type: "email", required: true, css: "is-invalid" }
4
});
5
6
...
7
8
const valid = email.validate();
Copied!
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 modified 1yr ago
Copy link