I don’t know how to call the validation directly but you can blur the elements telling yii to do it.
<button id="sendVlaidation" class="btn btn-success">Validate Form</button>
<script type="text/javascript">
$('#sendVlaidation').on('click', function() {
$('form :input').blur();
});
<script>
However, i think you meant to say it ISN’T triggering.
Regular form submittion via ajax.
The second example i posted will work on non multipart forms however, this one will not work on multipart forms.
$('#formId').on('beforeSubmit', function(event) {
event.preventDefault();
if ($(this).find('.has-error').length) {
return false;
} else {
$.ajax({
url: $(this).attr('action'),
type: $(this).attr('method'),
data: $(this)serialize(),
cache: false,
dataType: 'json',
error: function(xhr, status, error) {
alert('There was an error with your request! Error Type: ' + status + '. Error Message: ' + error + '.');
},
success: function(data) {
alert('Success...Do something.');
}
});
}
return false;
});
Ajax submit with multipart i.e. images / files
$('#formId').on('beforeSubmit', function(event) {
event.preventDefault();
if ($(this).find('.has-error').length) {
return false;
} else {
$.ajax({
url: $(this).attr('action'),
type: $(this).attr('method'),
data: new FormData($(this)[0]),
mimeType: 'multipart/form-data',
contentType: false,
cache: false,
processData: false,
dataType: 'json',
error: function(xhr, status, error) {
alert('There was an error with your request! Error Type: ' + status + '. Error Message: ' + error + '.');
},
success: function(data) {
alert('Success...Do something.');
}
});
}
return false;
});
If they don’t work you have an error somewhere else in your code. I just tried both of them and they work. Check your console for errors etc.