I have this code which shows a popover when there is a white space.
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
});
$('#validateForm').validate({
rules: {
product: {
required: true,
term: {regex: /^s*$/}
}
},
messages: {
product: {
required: "A text is much",
term: "Please avoid spaces"
},
},
showErrors: function (errorMap, errorList) {
$.each(this.successList, function (index, value) {
$('#'+value.id+'').popover('destroy');
});
$.each(errorList, function (index, value) {
$('#'+value.element.id+'').attr('data-content',value.message).popover({
placement: 'top',
trigger: 'manual'
}).popover('show');
});
}
});
What happens is, the popover doesnt get destroyed once there is no whitespace. What am i doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…