0
I have a dropdown and want to validate, make it mandatory only if a checkbox is checked, otherwise it is not required
I tried to do as Jsfiddler https://jsfiddle.net/dorathoto/zoh72rx5/6/
<form action="#" method="post" id="Form">
<input type="checkbox" id="L3chk" name="L3chk" value="true" />
<select id="RadioId" class="form-control" >
<option disabled selected>--- Selecione ---</option>
<option value="1">Opc 1</option>
<option value="2">Opc 2</option>
</select>
<button type="submit" class="btn btn-danger">Enviar</button>
</form>
$(document).ready(function () {
$("#Form").validate({
rules: {
RadioId: { required: "#L3chk:checked" }
}
})
});
But you don’t need the validate just for this, it only does with jQuery!
– LeAndrade