Button Click event fires when pressing Enter key in different input (no forms)

后端 未结 6 2096
离开以前
离开以前 2020-12-12 21:42

This logic is firing when pressing \"Enter\" in the \"Amount\" input, and I don\'t believe it should (it doesn\'t in Chrome). How can I prevent this, and if not prevent it

6条回答
  •  一整个雨季
    2020-12-12 22:16

    I was having this issue with ASP.NET WebForms:

    
    

    This can NOT be solved by just adding type="button" because ASP.NET replaces it with type="submit" (you can see this behavior in the browser if you inspect the element.)

    The correct way to do this in asp.net is to add

    
    

    to the button. ASP will automatically add the type="button" attribute.

提交回复
热议问题