I have this accordion with three steps, in the first step I ask for the first and last name.
How could I make steps 2 and 3 blocked until the user fills in the fields in step 1?
<fieldset id="accordion">
<label for="1" class="pasos">Step1</label>
<input class="hide_check" type="radio" name="toggle" id="1" value="1" checked>
<output>
<div>
<input placeholder="name" class="field__input" id="name" name="" required/>
<input placeholder="last name" class="field__input" id="last name" name="" required/>
</div>
</output>
<label for="2" class="pasos">Step2</label>
<input class="ocultar_check" type="radio" name="toggle" id="2" value="2">
<output>
<div>
<input placeholder="phone" class="field__input" id="phone" name="" required/>
</div>
</output>
<label for="3" class="pasos">Step 3</label>
<input class="ocultar_check" type="radio" name="toggle" id="3" value="3">
<output>
<div>
<input placeholder="address" class="field__input" id="address" name="" required/>
</div>
</output>
</fieldset>
For example, I fill in the fields in step 1 and if they are filled, I can just access step 2 and so on. If step 1 is not filled out, I can’t access the next steps. I’m new to js, any help is appreciated THANKS
2
Answers
This code will first check if all the fields in step 1 are filled in. If they are, it will enable step 2 by removing the ocultar_check class from the element and adding the active class to its next sibling element. This will make step 2 visible and accessible to the user.
try to use this code in js