disable enter key on specific textboxes

前端 未结 9 778
北荒
北荒 2020-12-30 18:25

I was looking for a way to do this, got a few scripts, but none of them is working for me.

When I hit enter in my textboxes, it shouldn\'t do anything.

I hav

9条回答
  •  离开以前
    2020-12-30 19:03

    I don't understand why everybody here is suggesting to use jquery. There is a very simple method for it for a specific input element field. You can use its onKeyDown attribute and use e.preventDefault() method in it. Like this:

     e.preventDefault()}/>
    

    Note: This is React JSX way of using this attribute you can use HTML basic way.

提交回复
热议问题