Basic structure html and form navigation #1
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rishav_dml/Assignment02-Multi-Step-Form-Wizard#1
Loading…
Reference in a new issue
No description provided.
Delete branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Only half way done.
@ -0,0 +44,4 @@
id="phone"
class="rounded p-1"
minlength="10"
maxlength="10"
replace maxlength and minlength with max and min
@ -0,0 +81,4 @@
name="age"
id="age"
class="rounded p-1"
pattern="^(1[89]|[2-9][0-9]|100)*$"
Replaced regex with min="18" and max="100"
@ -0,0 +1,56 @@
// const form = document.getElementById("personal-details-form"); // Main form element
remove the commented code
@ -0,0 +27,4 @@
const forms = document.querySelectorAll("[data-form]");
var currentStep = 0;
var currentForm = forms[currentStep];
function decrementStep() {
// Prevent going to a negative step
currentStep = Math.max(currentStep - 1, 0);
handleFormVisibility();
}
@ -0,0 +28,4 @@
var currentStep = 0;
var currentForm = forms[currentStep];
function incrementStep() {
function incrementStep() {
if (!validateForm()) return; // Early exit if form is invalid
// Proceed to next step
currentStep = Math.min(currentStep + 1, forms.length - 1); // Prevent going beyond the last form
handleFormVisibility();
}
I added Math.min and Math.max to ensure that currentStep doesn't go out of bounds(below 0)
if (!validateForm()) return;
This is causing some unknown behavior, therefore not including this.