I have multiple textboxes, every textbox has a related hidden field, the hidden field’s ID is a concatenation of a string with the model’s ID (ex: “FormState25“)
How can I pass the ID of a hidden field when a textbox being changed? I’m using the following code to detect textbox change:
$("#body-content-container").on('change', 'input[type="text"]', function () {
$("#FormState").val('dirty');
});
You can add custom attributes to the textbox tag itself that includes the Id of the hidden field, for example:
In View
This way when a textbox get changed you can get the Id of the hidden field you already use to store whatever you want, and then modify the javascript to handle that hidden field’s Id, like this:
Javascript
The javascript will get the
HiddenFieldIdattribute of the corresponding hidden field from the textbox and change it’s value. Try this and let me know..