How can I check if a value is changed on blur event?

前端 未结 10 1357
时光说笑
时光说笑 2021-02-07 06:29

Basically I need to check if the value is changed in a textbox on the \'blur\' event so that if the value is not changed, I want to cancel the blur event.

If it possible

10条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 06:54

    Within the onblur event, you can compare the value against the defaultValue to determine whether a change happened:

    
    

    The defaultValue will contain the initial value of the object, whereas the value will contain the current value of the object after a change has been made.

    References:

    value vs defaultValue

提交回复
热议问题