copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
$(document).ready(function () {
|
||||
$('#forminvoice').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
var btn = $('#submit');
|
||||
|
||||
btn.attr('disabled', 'disabled').text('Wait...');
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr('action'),
|
||||
data: $(this).serialize(),
|
||||
type: 'POST',
|
||||
success: function (response) {
|
||||
btn.removeAttr('disabled').text('Submit');
|
||||
if (response.status) {
|
||||
window.location.href = base_url + 'index.php/ManageInvoice';
|
||||
} else {
|
||||
|
||||
$.each(response.errors, function (key, val) {
|
||||
$('[name="' + key + '"]').closest('.form-group').addClass('has-error');
|
||||
$('[name="' + key + '"]').nextAll('.help-block').eq(0).text(val);
|
||||
if (val === '') {
|
||||
$('[name="' + key + '"]').closest('.form-group').removeClass('has-error').addClass('has-success');
|
||||
$('[name="' + key + '"]').nextAll('.help-block').eq(0).text('');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$('#forminvoice input, #forminvoice select').on('change', function () {
|
||||
$(this).closest('.form-group').removeClass('has-error has-success');
|
||||
$(this).nextAll('.help-block').eq(0).text('');
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user