I use bootstrap and I created a form with 8 checkboxes. When a user clicks Submit, I want to check if at least one checkbox is checked, and if not, report this to the community with an error message below the checkbox group. In addition, I would like to check if the date that it sets matches with my default data form: 09/23/2015 05:45 PM
This is my java-script verification code:
$('#myform').validate({
errorElement: 'div',
rules: {
datetimepicker: {
required: true,
date: true
},
commercialText: {
required: true,
minlength: 5
},
terms: {
required: true,
maxlength: 2
}
},
submitHandler: function (form) {
var text = $("#customtext").val();
var date = $("#datetimepicker").val();
var stand = 2;
$.ajax({
url: 'savedatanow.php',
type: "POST",
data: {
text: text,
date: date,
stand: stand
},
dataType:'text',
success: function(response)
{
alert(response);
}
});
},
highlight: function (element) {
$(element).closest('.form-group').removeClass('success').addClass('has-error');
},
success: function (element) {
element.addClass('valid')
.closest('.form-group').removeClass('error').addClass('has-success');
}
});
: http://jsfiddle.net/5WMff/1316/, . , , ( , ). ?
!