Reputation: 155
<input type="text" id="shareemail" name="shareemail" value="" data-role="tagsinput" />
$('input').on('itemAdded', function(event) {
var test = event.item;
var test2 = validateEmail(test);
if(!test2){
$('#shareemail').tagsinput({
tagClass: 'label label-danger label-important'
});
debugger;
}
});
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
I want to add some other class to tag if the tag is not a valid email as mentioned in the above code but tagClass is showing undefined. I am following bootstrap-tagsinput docs but its not working at my end. Please let me know how I can fix this problem.
Upvotes: 1
Views: 335