Jquery replace only specific characters : <p>I need to replace all special characters except #-. But below code allows all special characters after typing of above mentioned. </p>

<pre><code> $("[id='searchjobautotop']").keyup(function(e){
            var start = this.selectionStart,
            end = this.selectionEnd;
            var data= $(this).val() ;
            var dataFull = data.replace(/[^0-9a-zA-Z#.- ]/g, '');
            if(e.which!=37 &amp;&amp; e.which!=39 &amp;&amp; data.length&lt;2)
            $(this).val(dataFull);
            this.setSelectionRange(start, end);

         });
</code></pre>

<p>Please make a JSFIDDLE sample for me.</p>
