You can accomplish this using the createSearchChoice parameter, which allows you to define a user-defined function to create tags from user input. To prevent tags containing non-alphanumeric characters, select2 should be initialized as follows:
$("#mySelect").select2({
createSearchChoice: function(term) {
if(term.match(/^[a-zA-Z0-9]+$/g))
return { id: term, text: term };
},
formatNoMatches: "Enter valid format text"})
, - , select2 . NoMatches, , " ", , .
Update:
select2 ~ 4.0 createTag