JSFiddle - React, Tailwind, and code Playground
by cathead
HTML
<label><input type="checkbox">address same as billing</label>
<div>
<label>First Name</label>
<input type="text">
</div>
JavaScript
var chk = $('#billing-information-checkbox');
var billingInformation = $('#billing-information');
var billingInformationInputs = $('#billing-information input:required');
if (billingCheckbox.is(':checked')) {
billingInformationInputs.prop('required', false);
} else {
billingInformationInputs.prop('required', true);
}
billingCheckbox.click(function () {
if (billingCheckbox.is(':checked')) {
billingInformationInputs.prop('required', false);
} else {
billingInformationInputs.prop('required', true);
}
});