I have a page that contains a HiddenField control, I register some javascript on page load which contains a function I want to run when the HiddenField value has changed.
Currently, I have the following code which executes the function if an input field’s value has changed:
$(':input').change(function(){ pageHasBeenUpdated = true; });
What javascript would I need to set pageHasBeenUpdated = true if the value of the HiddenField control has been updated?
You can access the hidden input elements by specifying it in an attribute selector:
Since the
changeevent isn’t triggered when you update the value of a hidden input field you’ll need to fire it yourself when you update the value of the input.Example:
Html
jQuery
Working Example