Permalink
Browse files

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.
  • Loading branch information...
1 parent ffac87c commit 1b461629fe8f0b0458d295f53d6136a8cac4ee72 @javiertoledo javiertoledo committed Jul 12, 2011
Showing with 13 additions and 0 deletions.
  1. +1 −0 jquery.tagsinput.css
  2. +12 −0 jquery.tagsinput.js
Oops, something went wrong.
View
@@ -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;
});

0 comments on commit 1b46162

Please sign in to comment.