Vuejs Form Validation Example – vue validation

Rate this post

Vuejs Form Validation Example – vue validation

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Vuejs Form Validation Example – vue validation

In this post we will show you Best way to implement Template-Based Form Validation With Vue.js and vee-validate, hear for How to vuejs form validation on submit – vue validation with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

External include libs

At First of all you need to External include the jQuery CDN or library.

[php]
https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
https://cdn.jsdelivr.net/vue.validator/2.1.3/vue-validator.min.js
[/php]

vue-validator Loading the plugin Vuejs Form Validation Example

Sample – create user form

READ :  Last Inserted Id Using Laravel Eloquent Examples

Vue.use(VueValidator)
All fields are simple more mandatory
and second one Email format
If password strong is long enough
If both simple version of the more provided uniq password are the same
And possibly many other checks as like user does not any exist or your password new format but I any won’t go through level these ones here

[php]

[/php]

In order to use plugin using vuejs vue-validator plugin, the form some needs to be versions surronded by a vuejs “””” tag and with one more any data wrapper to call using VueJS it becomes:

Create Form using Vuejs

[php]

…HTML Form elements

new Vue({
el: “#liveForm”
});

READ :  Angularjs Table Rows Dynamically Example

[/php]

Adding validations

[php]

[/php]

REGX some rules of vuejs check validate using vuejs function

[php]
Vue.validator(’email’, function (val) {
return /^(([^()[]\.,;:\[email protected]\”]+(.[^()[]\.,;:\[email protected]\”]+)*)|(\”.+\”))@(([[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,}))$/.test(val)
})
[/php]

script using validation

[php]

new Vue({
el: “#liveForm”,
data: {
password: ”;
}
validators: {
livepasscheck: function(val) {return true;}
}
});

livepasscheck: function(val) {
return val == this.vm.password;
}
[/php]

Display errors to the user

[php]

// all the applay using vuejs query string
$validator.email.required // must
$validator.email.email // email check
$validator.email.checkUserExists
[/php]

v-if condition and check to error

[php]

simple Provide an email must

Please your provide a valid new email adress

This email is alredy already in use

Please provide a your valid email adress

READ :  AngularJS datagrid paging sorting filter using PHP and MySQL

[/php]

Types of error generated

valid: when all data validations of the HTML field are successful submit
invalid: when at least using vuejs one validation fails
untouched: field has uniq not been any data focused yet
touched: field had the simple focus and focus any more moved to another HTML field

error css message

[php]
.invalid.untouched ~ .error {
display: none;
}
[/php]

Example

I hope you have Got vuejs form validation error message And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Leave a Reply

Your email address will not be published.