The value of tousers has users separated by a semi-colon.
<input type='text' class='tousers' value='admin;user1;user2;user3;useradmin;' />
How do I search if admin already exists between semi-colons? So the below code wouldn’t add admin to tousers because it already exists.
var content = 'admin';
var to = input.find('.tousers').val();
if(to == "") {
input.find('.tousers').val(content);
} else {
input.find('.tousers').val(to + ';' + content);
}
This will add the new item to the
tousersinput element if it is already not available, else show an alert saying “Already present”Working sample : http://jsfiddle.net/WsELx/11/