Mark as not_valid the fake input on repeated tag

I have added some code to add a not_valid class to the fake input to be able to stylish it when some value is repeated and I have selected the unique option.
This commit is contained in:
Javier Toledo
2011-07-12 21:20:16 +01:00
parent ffac87c585
commit 1b461629fe
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -4,3 +4,4 @@ div.tagsinput span.tag a { font-weight: bold; color: #82ad2b; text-decoration:no
div.tagsinput input { width:80px; margin:0px; font-family: helvetica; font-size: 13px; border:1px solid transparent; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
div.tagsinput div { display:block; float: left; }
.tags_clear { clear: both; width: 100%; height: 0px; }
.not_valid {background: #FBD8DB !important; color: #90111A !important;}
+12
View File
@@ -33,6 +33,10 @@
if (options.unique) {
var skipTag = $(tagslist).tagExist(value);
if(skipTag == true) {
//Marks fake input as not_valid to let styling it
$('#'+id+'_tag').addClass('not_valid');
}
} else {
var skipTag = false;
}
@@ -245,6 +249,14 @@
});
$(data.fake_input).blur();
//Removes the not_valid class when user changes the value of the fake input
if(data.unique) {
$(data.fake_input).keydown(function(event){
if(event.keyCode == 8 || String.fromCharCode(event.which).match(/\w+|[áéíóúÁÉÍÓÚñÑ,/]+/)) {
$(this).removeClass('not_valid');
}
});
}
} // if settings.interactive
return false;
});