I have a web form with a hidden input field as follows:
<input id="requiredFields" name="requiredFields" type="hidden" value="firstname,lastname,email,phone">
I want to add and remove ",location" based on a certain condition using jQuery as follows:
$('input[name="locationstatus"]:radio').on("change", function() {
if ($('input[name="locationstatus"]:radio:checked').val() == 'Yes') {
/* need syntax to append text ',location' to #requiredFields string */
}
else {
/* need syntax to remove text ',location' from #requiredFields string */
}
});
Thanks