Currently, I am utilizing Vue.js along with Bootstrap for the creation of a website. In this process, I have set up a form on which I am implementing my custom validation logic. Everything seems to be functioning correctly until the moment when the user hits the submit button and the was-validated
class is added to the form as per Bootstrap guidelines.
The issue arises at this point, where any required input field with any input - regardless of whether it validates based on my custom logic or not - is marked as valid, displaying a green border and check mark. Interestingly, my custom validation still runs in the background and shows the error message using b-form-invalid-feedback
. However, it appears that the was-validated
class considers fields with the required property as valid without factoring in my custom validation, resulting in conflicting validation scenarios. A field could have a green check mark due to meeting the required property, yet still display an error because it doesn't pass my custom checks.
I have attempted to remove the :valid
style; however, this didn't produce the desired effect as I do want those styles to show up when the field satisfies my custom validation criteria. If this explanation is unclear, I can provide visuals for better understanding. Additionally, there is another issue I encountered - a date picker that fails to trigger the appearance of b-form-invalid-feedback
even after adding was-validated
.
Snippet of My Code
<b-form @submit.prevent="addReview" name="review-form" novalidate>
<div class="name">
...
</div>
...
<div class="description">
...
</div>
<b-button type="submit">Save</b-button>
</b-form>
...
Computed Properties and Methods Used
computed: {
emailStateValidation() {
...
},
domainStateValidation() {
...
},
},
methods: {
emailIsValid() {
...
},
domainIsValid() {
...
},
isStateValid(variable) {
...
},
addReview() {
...
...
Specific Questions:
- How can I resolve the conflict between the required attribute and my custom validation to prevent premature marking of input fields as valid?
- Why is the
b-form-invalid-feedback
not showing up on the datepicker component upon form submission if a date is not selected?