I have some code as below:
<label class="control-label col-sm-4" for="datepicker">Date of Birth</label>
<div class="col-sm-8" ><input class="form-control col-sm-10" type="text" id="datepicker" name="datepicker" required="true" value="<?php if(isset($_SESSION['DOB'])) echo $_SESSION['DOB'] ?>"></div>
My issue is that I don't want this "Date of Birth" field to be a required field anymore. How do I set this field as unrequired?
I have tried setting required="false" but this does not work.
Any advice much appreciated, many thanks Jean-Claude
The required attribute does not take the attribute value. It's just required="true", or required="required", or just setting the
<input type="text" required />
would make it required as well. Just unset the required attribute. If you're trying to unset it after some user action (with javascript) then use the .removeAttribute("required") function.
<label class="control-label col-sm-4" for="datepicker">Date of Birth</label>
<div class="col-sm-8" ><input class="form-control col-sm-10" type="text" id="datepicker" name="datepicker" value="<?php if(isset($_SESSION['DOB'])) echo $_SESSION['DOB'] ?>"></div>
Avoid using required if you don't need them.
Also the attributes that are not necessary must be avoided.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With