Answer the question
In order to leave comments, you need to log in
How to properly implement a module or plugin in vue js that implements some "standard" behavior for input fields?
Hello! I'm trying to learn vuejs, for simple things everything is pretty clear.
However, I got to the point where I wanted to automate the validation of input fields on forms.
I wrote a TK that I can easily implement without using vue js, here it is:
---------------------------------- -------------------------
Purpose
Make support for the data-validators attribute on input fields
input[type=text]
input[type=number]
input[type =password]
input[type=email]
Works with standard bootstrap 4.2.1 input fields like
<div class="col-md-6 mb-3">
<label for="iPassword">Password</label>
<input type="password" class="form-control is-invalid" id="iPassword" placeholder="Enter password" required>
<div class="invalid-feedback">
Password must containts numbers and letters different case: upper and lower.
</div>
</div>
window.oB421Validator = new B421Validator(window.Localizator.t);
oB421Validator = new B421Validator(t);
<div class="col-md-6 mb-3">
<label for="iPassword">Password</label>
<input placeholder="$t('Enter password')" v-model="password" v-bind:class="passwordIsInvalid" type="password" name="iPassword" required>
<div class="invalid-feedback">
{{ passwordError }}
</div>
</div>
Answer the question
In order to leave comments, you need to log in
As Arthur correctly wrote in the comment, vuejs has the ability to create custom directives. This made it possible to implement the TOR with a margin of flexibility for various kinds of changes. Brief documentation and implementation uploaded here . In the near future I will try to test for flexibility by applying it in bootstrap 3 and in bootstrap 4.0.0 beta.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question