Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 to check it the value is changed by user on the blur event of an input HTML element?

like image 806
pencilCake Avatar asked Feb 25 '10 10:02

pencilCake


People also ask

What is the default value of Blur property?

There is no default value of HTML onblur attribute.

What is the difference between onChange and Onblur?

onChange is when something within a field changes eg, you write something in a text input. onBlur is when you take focus away from a field eg, you were writing in a text input and you have clicked off it.

Does blur trigger Focusout?

The blur event fires when an element has lost focus. The main difference between this event and focusout is that focusout bubbles while blur does not. The opposite of blur is focus . This event is not cancelable and does not bubble.

What is blur () method?

blur() method removes keyboard focus from the current element.


1 Answers

I don't think there is a native way to do this. What I would do is, add a function to the focus event that saves the current value into a variable attached to the element (element.oldValue = element.value). You could check against that value onBLur.

like image 191
Pekka Avatar answered Sep 21 '22 18:09

Pekka