Input Fires Keypress Event Twice

后端 未结 8 2229
小蘑菇
小蘑菇 2021-02-18 14:26

This question has been asked/answered (mostly) before, BUT I\'ve tried three things to stop the event from bubbling but nothing has worked:

return false;
e.stopPr         


        
8条回答
  •  太阳男子
    2021-02-18 14:44

    Hope this will solve your problem. Instead of using event.preventDefault() use these two shown below. In case of Microsoft browsers use event.cancelBubble = true; In case of W3C model browsers use event.stopPropagation();

    And Instead of Keyup event kindly use the keypress event, because during keypress itself the input will be sent to input field so whatever inputs you don't want to appear will appear on the field. So the enter button event will be triggered.

    Instead of return false use event.returnValue = false.

提交回复
热议问题