Bharat Koshti
Bharat Koshti

Reputation: 81

How to Delete /Remove input values on backspace key

How do I delete/remove input values on backspace using javascript or jquery? I entered several email ids in a textbox by separating them with comma, tab etc. On backspace key I want to delete the input values one by one.

Please give any function to implement this functionality.


Here is my front end code:

<div class="textarea-wrapper topspacing-subsection leftspacing-subsection ">
    <div class="textarea wordcontainer" style="display:inline-block;width:690px;" onclick="javascript:document.getElementById('txtSendFromType').focus();">
        <%--width 372 px removed from  txtSendFromType--%>
            <asp:TextBox ID="txtSendFromType" runat="server" CssClass="word" BorderStyle="None" AutoCompleteType="Disabled" onkeypress="this.style.width = ((this.value.length + 1) * 8) + 'px';"></asp:TextBox>
    </div>
</div>

Upvotes: 0

Views: 3948

Answers (1)

Anuj Kumar
Anuj Kumar

Reputation: 160

Use this, hope it helps you:

var input = document.getElementById('txtSendFromType');
  input.onkeydown = function() {
  var key = event.keyCode || event.charCode;
  if( key == 8 || key == 46 )
    return false;   
};

Upvotes: 1

Related Questions