1
I have a field in my PHP form where I ask if the user has a phone at home. It is a select with YES and NO. If YES the following field must be required to be completed, if NO, the field will not be required.
<div class="col-sm-4 form-group">
<label for="telcasa"> Telefone de Casa:</label>
<select required name="telcasa" required class="form-control" id="telcasa">
<option value="escolhaopcao">Selecione</option>
<option value="Sim">Sim</option>
<option value="Não">Não</option>
</select>
</div>
<div class="col-sm-8 form-group">
<label for="telefone_casa">Caso sua resposta seja sim, deixe o número aqui: </label>
<input name="telefone_casa" type="number" required class="form-control" id="telefone_casa" maxlength="50">
</div>
How do I make that rule work? If the selection is YES the field If your answer is yes, leave the number here: it will be mandatory, if No, it will not be required.
Follow picture of the fields:
Hi friend, thanks for the contact, did not work :(
– Alessandro Ramos
What’s showing up? What do you really want?
– Taffarel Xavier
So friend, with the selection of the NO the field of the phone_home is still mandatory the filling. It should be released, according to the function you sent me, correct? Do I have to remove the "required" from this line: <input name="phone_home" type="number" required class="form-control" id="phone_home" maxlength="50">
– Alessandro Ramos
In fact, if you are using Jquery, this is already done automatically, as I described in the code I sent.
– Taffarel Xavier
That’s what I figured
– Alessandro Ramos
https://repl.it/@TaffarelXavier/LatestAustereEfficiency
– Taffarel Xavier