OK So I have a validation I am calling on blur from an input box. I pass the ID and limits it validates against into that method. I am using Bootstrap Vue for the popover that the validations it is pushed too.
But my question is why doesnt the validation work the first time it is called. For the sake of explaining let's say you can't order over 5 for a product and you enter 10 into the quantity box and mouse out of the box. Nothing happens, but if you mouse into the same box and mouse out it shows the validation error.
Input Box with popover
Here is the Mixin / Function that gets called on blur. methods:{ limitChecking(id, limits) { // Reset the Popup and Error Message this.$root.$emit('bv::hide::popover') var inputValue = document.getElementById("input-"+id).value this.errorMessage = 'Quantity entered is too high: \n' var validations = ""
validations = this.findAllValidation(limits, inputValue)
this.errorMessage = this.errorMessage + validations
if(validations.length === 0 && inputValue > 0){
document.getElementById("button-"+id).disabled = false;
}else if (inputValue <= 0){
document.getElementById("button-"+id).disabled = true;
}else{
this.fireValidationPopover(id)
}
},
findAllValidation(limits, inputValue){
var validations = ""
for (var key in limits) {
if (limits.hasOwnProperty(key)) {
if(inputValue > limits[key].value){
validations += limits[key].name + " " + limits[key].value + "\n"
}
}
}
return validations
},
fireValidationPopover(id){
document.getElementById("button-"+id).disabled = true;
this.$root.$emit('bv::show::popover', "popover-"+id);
}
} // End Methods