bootstrap-select
bootstrap-select copied to clipboard
Validation Tag without message (empty)
HTML tag with the validation message is displayed even without the validation message text content. So you see a piece of visual TAG </ span> but empty.
How to TAG display only when actually exist message on it?
duplicate of #1361
Hi, here is a workaround :
Pure JS :
var elem = document.getElementById('_YOURELEMID_');
elem.addEventListener('invalid', function (event) {
if(elem.validity.valueMissing) {
elem.setCustomValidity('_YOURMESSAGE_');
} else {
elem.setCustomValidity('');
}
});
With jQuery :
$('_YOURELEMID_').on('invalid', function (event) {
if(this.validity.valueMissing) {
this.setCustomValidity('_YOURMESSAGE_');
}else {
elem.setCustomValidity('');
}
})