check form is valid in bootstaap jquery code example
Example 1: check if form bootstrap is valid js
function form_validate(attr_id){
var result = true;
$('#'+attr_id).validator('validate');
$('#'+attr_id+' .form-group').each(function(){
if($(this).hasClass('has-error')){
result = false;
return false;
}
});
return result;
}
Example 2: bootstrap 4 form validator with jquery
$(document).ready(function() {
$("#submitButton").click(function() {
var form = $("#signup-form");
if (form[0].checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.addClass('was-validated');
})
})