Forums

Changing field error tooltip works just once.

marcomax 14 Mar, 2019
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.

healyhatman 14 Mar, 2019
Have you tried changing the text of the error message directly?
marcomax 14 Mar, 2019
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.
healyhatman 14 Mar, 2019
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.