mysterious-toddler-20573
05/28/2023, 10:13 PMhttps://cdn.discordapp.com/attachments/725789747212976259/1112503927351545946/image.png▾
mysterious-toddler-20573
05/28/2023, 10:16 PMapplescript
on input debounced at 200ms
add .btn-disabled to the #submitButton
for field in <[data-initalValue]/> in me
if the field's @data-initialValue is not equal to the field's value then
remove .btn-disabled from the #submitButton then exit
mysterious-toddler-20573
05/28/2023, 10:17 PMbrash-house-85887
05/28/2023, 10:17 PMmysterious-toddler-20573
05/28/2023, 10:17 PMmysterious-toddler-20573
05/28/2023, 10:17 PM< ... />
can be a general CSS selectormysterious-toddler-20573
05/28/2023, 10:18 PMbrash-house-85887
05/28/2023, 10:20 PMis not equal to the
generates an error for me, but is not the
works. Updated the gist with what works. https://gist.github.com/geoffeg/28126ccf63ff958544adf527a81a788bmysterious-toddler-20573
05/28/2023, 10:28 PMmysterious-toddler-20573
05/28/2023, 10:34 PMmysterious-toddler-20573
05/28/2023, 10:34 PMbrash-house-85887
05/28/2023, 10:36 PMmysterious-toddler-20573
05/28/2023, 10:40 PMbrash-house-85887
05/28/2023, 10:49 PMgreat-cartoon-12331
05/28/2023, 11:08 PMfreezing-waitress-26396
05/28/2023, 11:13 PMbehavior validateForm
on click or change or input
set validated to my.checkValidity()
if validated tell the first <button[type='submit']/> in me remove [@disabled] end
else tell the first <button[type='submit']/> in me add [@disabled] end
end
end
freezing-waitress-26396
05/28/2023, 11:14 PMbrash-house-85887
05/28/2023, 11:16 PMfreezing-waitress-26396
05/28/2023, 11:23 PMfreezing-waitress-26396
05/28/2023, 11:23 PMvalidateForm
stay as basic as it is above? 🤔mysterious-toddler-20573
05/28/2023, 11:28 PMhigh-iron-12893
05/28/2023, 11:40 PMhx-trigger
on the hidden.bs.modal
event bootstrap fires when a modal is done hiding but not sure if there's a more idiomatic way to do it. gray-morning-3453
05/29/2023, 12:14 AMfunction hasFormChanged(form) {
// Get all controls
const controls = form.querySelectorAll("input, textarea, select");
// Initialize flag
let changed = false;
// Loop through
controls.forEach(control => {
// Ignore controls that are disabled or readonly
if (control.disabled || control.readOnly) {
return;
}
if (control.type === "checkbox" || control.type === "radio") {
// For checkboxes and radio buttons, compare checked state to defaultChecked state
if (control.checked !== control.defaultChecked) {
changed = true;
}
} else if (control.tagName === "SELECT") {
// For select elements, compare selected options to defaultSelected options
const selectedOptions = Array.from(control.options).filter(option => option.selected);
const defaultSelectedOptions = Array.from(control.options).filter(option => option.defaultSelected);
if (selectedOptions.length !== defaultSelectedOptions.length) {
changed = true;
} else {
for (let i = 0; i < selectedOptions.length; i++) {
if (selectedOptions[i] !== defaultSelectedOptions[i]) {
changed = true;
break;
}
}
}
} else {
// For all other form controls, compare current value to defaultValue
if (control.value !== control.defaultValue) {
changed = true;
}
}
});
return changed;
}
gray-morning-3453
05/29/2023, 12:15 AMgray-morning-3453
05/29/2023, 12:16 AMswift-spring-80795
05/29/2023, 2:22 AMgreat-cartoon-12331
05/29/2023, 2:23 AMswift-spring-80795
05/29/2023, 2:36 AMgreat-cartoon-12331
05/29/2023, 2:37 AM