Get started with vue-validator CDN
MIT licensed
Vue-validator is a validation library for Vue.js applications.
Tags:- plugin
- validation
- vue
Stable version
Copied!
How to start using vue-validator CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with vue-validator CDN - cdnhub.io</title>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-router.min.js"></script>
<script src="https://cdn.cdnhub.io/vue-validator/2.1.7/vue-validator.min.js"></script>
</head>
<body>
<div id="app">
<form @submit.prevent="validateForm">
<input v-model="email" type="email" name="email" class="form-control" :class="{ 'is-invalid': $v.email.$error }" placeholder="Email">
<span class="invalid-feedback" v-if="$v.email.$error">{{ $v.email.$errors[0].$message }}</span>
<input v-model="password" type="password" name="password" class="form-control" :class="{ 'is-invalid': $v.password.$error }" placeholder="Password">
<span class="invalid-feedback" v-if="$v.password.$error">{{ $v.password.$errors[0].$message }}</span>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<script>
Vue.use(Vue);
Vue.use(VueRouter);
Vue.use(VueValidator);
const router = new VueRouter({
mode: 'div',
routes: []
});
const app = new Vue({
el: '#app',
router,
data: {
email: '',
password: '',
$valid: false
},
validations: {
email: { required, email },
password: { required, minLength: minLength(6) }
},
methods: {
validateForm() {
this.$v.$touch();
this.$valid = this.$v.$invalid;
}
}
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
0.1.0
0.1.1
0.10.0
0.11.0
0.11.1
0.11.2
1.0.0
1.0.1
1.0.2
1.0.3
1.0.4
1.0.5
1.0.6
1.0.7
1.1.0
1.1.1
1.1.2
1.2.0
1.2.1
1.2.2
1.3.0
1.3.1
1.3.2
1.3.3
1.4.0
1.4.1
1.4.2
1.4.3
1.4.4
2.0.0
2.0.0-alpha.1
2.0.0-alpha.10
2.0.0-alpha.11
2.0.0-alpha.12
2.0.0-alpha.13
2.0.0-alpha.14
2.0.0-alpha.15
2.0.0-alpha.16
2.0.0-alpha.17
2.0.0-alpha.18
2.0.0-alpha.19
2.0.0-alpha.2
2.0.0-alpha.20
2.0.0-alpha.21
2.0.0-alpha.22
2.0.0-alpha.3
2.0.0-alpha.4
2.0.0-alpha.5
2.0.0-alpha.6
2.0.0-alpha.7
2.0.0-alpha.8
2.0.0-alpha.9
2.0.0-beta.1
2.0.0-beta.2
2.0.0-beta.3
2.0.0-beta.4
2.0.0-beta.5
2.0.0-beta.6
2.0.1
2.0.2
2.1.0
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
2.1.6
*** 2.1.7
3.0.0-alpha.1
3.0.0-alpha.2