How to determine the change in value in a hidden input field

I have textarea in my MVC application where I implement AspNetSpellCheck , the debugger tells me that textarea changing to display: none; visibility: hidden; display: none; visibility: hidden; and a div generated using id="abc" and class"="pqr" .

 <input type="hidden" value="" name="userid" id="useid" /> 

I also implement change detection for all text areas and other controls ....

 var somethingChanged = false; $(document).ready(function() { $('input').change(function() { somethingChanged = true; }); }); 

As the text area becomes hidden, I assume that it does not automatically trigger the change() event. What is the solution to trigger the event in the above case? Thank you

EDIT

Using AspNetSpellCheck below is the code,

  @{ ASPNetSpell.Razor.SpellAsYouType mySpell = new ASPNetSpell.Razor.SpellAsYouType(); mySpell.InstallationPath = ("/Content/ASPNetSpellInclude"); mySpell.FieldsToSpellCheck = "TextArea1"; } <textarea id="TextArea1" cols="20" rows="2">bedddly</textarea> @Html.Raw(mySpell.getHtml()) <script type="text/javascript" language="javascript"> $(document).ready(function () { $('input[type="hidden"]').change(function () { debugger; alert('hi'); // somethingChanged = true; }); }); </script> 

The debugger produces below code, a hidden text area and a new DIV construct,

  <div tabIndex="null" class="livespell_textarea" id="TextArea1___livespell_proxy"> <textarea id="TextArea1" style="display: none; visibility: hidden;" rows="2" cols="20"> 
+7
source share
3 answers

if you do not know when the value changes in the text field, you can use setInterval to monitor the change

For example,

 objTextBox = document.getElementById("TextArea1"); oldValue = objTextBox.value; var somethingChanged = false; function track_change() { if(objTextBox.value != oldValue) { oldValue = objTextBox.value; somethingChanged = true; alert("something has Changed ") }); } } setInterval(function() { track_change()}, 100); 
+4
source

With hidden values, you need to trigger the change event yourself:

 $('#hiddenInput').val('newval').trigger('change'); 
+14
source

Try it. Launch an event.

 $('input[type="hidden"]').change(function() { alert('hi'); // somethingChanged = true; }); $('#useid').val("20").change(); 

Fiddle

+2
source

All Articles