quantities are now option and can also be fractions

This commit is contained in:
durn
2026-04-23 11:02:03 -06:00
parent ff3137c4b6
commit 6bafcd6f63
4 changed files with 29 additions and 17 deletions
@@ -60,12 +60,12 @@
</div>
<div class="field">
<label for="prep">Preparation Time: <span class="required">*</span></label>
<label for="prep">Preparation Time in Minutes: <span class="required">*</span></label>
<input type="text" id="prep" placeholder="0">
</div>
<div class="field">
<label for="cooking">Cooking Time: <span class="required">*</span></label>
<label for="cooking">Cooking Time in Minutes: <span class="required">*</span></label>
<input type="text" id="cooking" placeholder="0">
</div>
@@ -379,10 +379,22 @@ function validateForm() {
valid = false;
}
if (!qtyInput.value.trim() || isNaN(Number(qtyInput.value)) || Number(qtyInput.value) <= 0) {
showError(qtyInput, 'Enter a valid quantity');
const qtyVal = qtyInput.value.trim();
if (!isValidQuantity(qtyVal)) {
showError(qtyInput, 'Enter a valid quantity (e.g. 2, 1.5, 1/2, 1 1/2) or leave blank');
valid = false;
}
function isValidQuantity(val) {
if (val === '') return true;
if (!isNaN(Number(val))) return true;
if (/^\d+\/\d+$/.test(val)) return true;
if (/^\d+\s+\d+\/\d+$/.test(val)) return true;
return false;
}
});
const stepAreas = [...document.querySelectorAll('#steps-container textarea')];