mirror of
https://gitlab.com/etc404/software-engineering-project.git
synced 2026-05-10 20:52:58 +00:00
quantities are now option and can also be fractions
This commit is contained in:
@@ -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')];
|
||||
|
||||
Reference in New Issue
Block a user