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.
Select your desired component from below and see the available props, slots, events and functions.
Below is a collection of simple to complex examples.
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.
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 is a simple, lightweight model-based validation for Vue.js. Documentation
Vee-validate 폼을 체크하는 것을 도와주는 또 다른 유효성 검사 플러그인입니다. 한가지 주의사항(caveat)은 value prop을 사용할때
v-checkbox를 제대로 검사하기 위해 반드시 type="checkbox" 를 추가해야 한다는 점입니다
Ready for more? Continue reading with: