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.
Have you tried changing the text of the error message directly?
As far as I know, the tooltip takes its text from the field 'title' attribute. Is there another way to change tooltip text for a given field besides using 'title'?
JS can change the 'title' attribute correctly, just tooltip still pops up the old one.
JS can change the 'title' attribute correctly, just tooltip still pops up the old one.
It'll be in the Semantic UI form validation documentation somewhere I'll have a look later
This topic is locked and no more replies can be posted.
