3
I’m using http://www.bootstraptoggle.com/, a simple toggle of true or false.
Here is the code:
View:
<form id="myform">
@Html.CheckBoxFor(model => model.Permitir, new { id = "toggle1", data_on = "Sim", data_off = "Não", data_toggle = "toggle", data_class = "fast", data_size = "mini", data_onstyle = "success", data_offstyle = "danger" })
@Html.ValidationMessageFor(model => model.Permitir, "", new { @class = "text-danger" })
</form>
<input type="submit" class="btn btn-success" value="Adicionar" />
Javascript:
$(function () {
$('#toggle1').bootstrapToggle();
$('#toggle2').bootstrapToggle();
$('#toggle3').bootstrapToggle();
$('#toggle4').bootstrapToggle();
});
$("#myform").validate({
ignore: ":hidden",
rules: {
Permitir: { required: true}
},
messages: {
Permitir: "<span style=\"color: #a94442;\">Campo Permitir é obrigatório *</span>"
}, ....
The "Allow" field is required. It needs to look true. Validate is not working. Any solution ?