I am trying to set different error tooltip using JS, setting the title attribute.
Example:
if (quantity > mpi) {
errormsg = 'quantity cannot be over '+mpi;
document.getElementById('quantity').setAttribute('title',errormsg);
console.log (document.getElementById('quantity').title);
console.log(errormsg);
return false;
}
mpi changes according to the product, different products has different limits.
What happens:
user select a product and quantity, trigger an error.
user select another product that has a different mpi value, at this point the error tooltip doesn't change.
I checked the console logs for title and errormsg and it shows the correct one but for some reason the tooltip show the first msg.
Any suggestion? Thank you.
Example:
if (quantity > mpi) {
errormsg = 'quantity cannot be over '+mpi;
document.getElementById('quantity').setAttribute('title',errormsg);
console.log (document.getElementById('quantity').title);
console.log(errormsg);
return false;
}
mpi changes according to the product, different products has different limits.
What happens:
user select a product and quantity, trigger an error.
user select another product that has a different mpi value, at this point the error tooltip doesn't change.
I checked the console logs for title and errormsg and it shows the correct one but for some reason the tooltip show the first msg.
Any suggestion? Thank you.