Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
Javier Toledo committed Jul 12, 2011
1 parent ffac87c commit 1b46162
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions jquery.tagsinput.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions jquery.tagsinput.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
});
Expand Down

0 comments on commit 1b46162

Please sign in to comment.