Form

When it comes to form validation, Vuetify has a multitude of integrations and baked in functionality. Want to use a 3rd party validation plugin? Out of the box you can use Vee-validate and vuelidate.

Usage

The internal v-form component makes it easy to add validation to form inputs. All input components have a rules prop which takes an array of functions. These functions allow you to specify conditions in which the field is valid or invalid. Whenever the value of an input is changed, each function in the array will receive the new value. If a function returns false or a string, validation has failed.

API

v-form
Name
lazy-validation
Default
false
Type
boolean

If enabled, value will always be true unless there are visible validation errors. You can still call validate() to manually trigger validation

Name
value
Default
false
Type
boolean

A boolean value representing the validity of the form.

Examples

Creating rules

Rules allow you to apply custom validation on all form components. These are validated sequentially and will display a maximum of 1 error at a time, so make sure you order your rules accordingly.

Validation with submit & clear

The v-form component has three functions that can be accessed by setting a ref on the component. A ref allows us to access internal methods on a component, for example, <v-form ref="form">. this.$refs.form.validate() will validate all inputs and return if they are all valid or not. this.$refs.form.reset() will clear all inputs and reset their validation errors. this.$refs.form.resetValidation() will only reset input validation and not alter their state.

Vuelidate

vuelidate is a simple, lightweight model-based validation for Vue.js. Documentation

Vee-validate

vee-validate is a template Based Validation Framework for Vue.js. Documentation

Edit this page | language on Github
Vuetify 3 is now available!The latest version of Vuetify is now available!
Learn about Vuetify 3's new features and functionality for modern Vue applications
Start exploringExplore