VueJS Form Validation Example
In this Post We Will Explain About is VueJS Form Validation Example With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Form Validation with Vue JS Example
In this post we will show you Best way to implement Simple Vue Validator example, hear for Form Validation using Vue.js 2 with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
Form Validation with Vue.js
In this Example,First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priorty set.After that Include your relavant CSS Class.
Include External libs
https://cdn.firebase.com/js/client/2.2.9/firebase.js https://cdn.jsdelivr.net/vue/latest/vue.js
index.html
- {{stud.name}} - {{stud.email}}
- Student Name cannot be empty.
- Please provide a valid Student email address.
index.js
var baseURL = 'https://www.pakainfo.com/' var emailRE = /^(([^()[\]\\.,;:\s@\"]+(\.[^()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ /** * Setup firebase sync */ var Students = new Firebase(baseURL + 'students') Students.on('child_added', function (livedatasnap) { var stud_class = livedatasnap.val() stud_class.id = livedatasnap.key() liveApp.students.push(stud_class) }) Students.on('child_removed', function (livedatasnap) { var id = livedatasnap.key() liveApp.students.some(function (stud) { if (stud.id === id) { liveApp.students.$remove(stud) return true } }) }) /** * Create Vue liveApp */ var liveApp = new Vue({ // element to mount to el: '#liveApp', // initial data data: { students: [], newstudent: { name: '', email: '' } }, //addStudent computed property for form validation state computed: { validation: function () { return { name: !!this.newstudent.name.trim(), email: emailRE.test(this.newstudent.email) } }, isValid: function () { var validation = this.validation return Object.keys(validation).every(function (key) { return validation[key] }) } }, //addStudent methods methods: { addStudent: function () { if (this.isValid) { Students.push(this.newstudent) this.newstudent.name = '' this.newstudent.email = '' } }, removeStudent: function (stud) { new Firebase(baseURL + 'students/' + stud.id).remove() } } })
style.css
body { font-family: Helvetica, Arial, sans-serif; } ul { padding: 0; } .stud { height: 30px; line-height: 30px; padding: 10px; border-top: 1px solid #eee; overflow: hidden; transition: all .25s ease; } .stud:last-child { border-bottom: 1px solid #eee; } .v-enter, .v-leave { height: 0; padding-top: 0; padding-bottom: 0; border-top-width: 0; border-bottom-width: 0; } .errors { color: #f00; }
You are Most welcome in my youtube Channel Please shubscibe my channel. and give me FeedBack.
More Details……
Angularjs Example
I hope you have Got What is Model-based Form Validation with Vue.js and Vuelidate And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.