Skip to content
Advertisement

jQuery input value change detection

How to detect was input value changed or not on blur event?

For example every input field have default value (can be empty), after current input loses it’s focus we should determine, have the value been changed.

How to do this?

Advertisement

Answer

compare the value and the defaultValue

<input onblur="if(this.value!=this.defaultValue){alert('changed');}">
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement