How will i prevent duplication of value and empty value
<p>How can I prevent duplicate values being added to a combobox? I also need to prevent the space value. This is my code but its not working.</p>

<p>An entry is entered the first time input but the second time I enter input its alerting me that I have entered a duplicate value even when I enter different values.</p>

<p>Please see this jsFiddle <a href="https://jsfiddle.net/adLxoakv/" rel="nofollow">https://jsfiddle.net/adLxoakv/</a></p>

<pre><code>&lt;HTML&gt;
        &lt;HEAD&gt;
        &lt;script type="text/javascript" src="http://code.jquery.com/jquery.min.js"&gt;&lt;/script&gt; 
            &lt;fieldset&gt;
                &lt;legend&gt;Combo box&lt;/legend&gt;
                Add to Combo: &lt;input type="text" name="txtCombo" id="txtCombo"/&gt;
                            Selected: &lt;input type="text" name="selected" id="selected"/&gt;
                            IMEI Selected: &lt;input type="text" name="imei" id="imei"/&gt;

                &lt;input type="button" id="button" value="Add" onclick="addCombo()"&gt;
                &lt;br/&gt;
                Combobox: &lt;select name="combo" multiple id="combo"&gt;&lt;/select&gt;
            &lt;/fieldset&gt;
        &lt;/BODY&gt;
    &lt;/HTML&gt;
    &lt;script&gt;

    $("#txtCombo").on("keydown", function (e) {
        return e.which !== 32;
    });


    $(document).ready(function() {

    $('#button').click(function(){

        var data = [];
        $.each($("#combo option:selected"), function() {
          data.push($(this).attr("value"));

        });
            $('#imei').val(data.join(","));;
    var count = $("#combo :selected").length;
    $('#selected').val(count);


      });

    });


        $("#combo").on('change',  function () {

    var count = $("#combo :selected").length;
    $('#selected').val(count);


    });
         var text = $("#text").val();


     function addCombo() {

            var textb = document.getElementById("txtCombo");
            var combo = document.getElementById("combo");
            var option = document.createElement("option");
            option.text = textb.value;
            option.value = textb.value;
            option.selected = true;
        if (textb.length == 0) {
          return false;
        }
           if (combo.length) {
          alert("Duplicate found");
          return false;
        }
            try {
                combo.add(option, null ); //Standard 
            }catch(error) {
                combo.add(option); // IE only
            }
            textb.value = "";
        }


        // separated by comma to textbox
        $(document).ready(function() {

      $("#combo").change(function() {
        var data = [];
        $.each($("#combo option:selected"), function() {
          data.push($(this).attr("value"));
        });
            $('#imei').val(data.join(","));;

      });

    });
    &lt;/script&gt;
</code></pre>