diff --git a/jquery.tagsinput.css b/jquery.tagsinput.css index f458143..c595e24 100644 --- a/jquery.tagsinput.css +++ b/jquery.tagsinput.css @@ -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;} diff --git a/jquery.tagsinput.js b/jquery.tagsinput.js index f1dcd12..af1fe2b 100644 --- a/jquery.tagsinput.js +++ b/jquery.tagsinput.js @@ -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; });