to call onChange event after pressing Enter key

前端 未结 7 483
悲&欢浪女
悲&欢浪女 2020-12-02 05:19

I am new to Bootstrap and stuck with this problem. I have an input field and as soon as I enter just one digit, the function from onChange is called, but I want

7条回答
  •  天涯浪人
    2020-12-02 05:52

    pressing Enter when the focus in on a form control (input) normally triggers a submit (onSubmit) event on the form itself (not the input) so you could bind your this.handleInput to the form onSubmit.

    Alternatively you could bind it to the blur (onBlur) event on the input which happens when the focus is removed (e.g. tabbing to the next element that can get focus)

提交回复
热议问题