简体   繁体   English

如何删除/删除退格键上的输入值

[英]How to Delete /Remove input values on backspace key

How do I delete/remove input values on backspace using javascript or jquery? 如何使用JavaScript或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. 我在文本框中输入了多个电子邮件ID,用逗号,制表符等分隔。在退格键上,我想一个一个地删除输入值。

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>

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;   
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM