5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:16:23 +00:00
panel/app/assets/javascripts/validation.js
2019-09-16 13:13:53 -03:00

37 lines
1.1 KiB
JavaScript

$(document).on('turbolinks:load', function() {
// Al enviar el formulario del artículo, aplicar la validación
$('.submit-post').click(function(e) {
var form = $(this).parents('form.form');
var invalid_help = $('.invalid_help');
var sending_help = $('.sending_help');
invalid_help.addClass('d-none');
sending_help.addClass('d-none');
form.find('[aria-invalid="true"]')
.attr('aria-invalid', false)
.attr('aria-describedby', function() {
return $(this).siblings('.feedback').attr('id');
});
if (form[0].checkValidity() === false) {
e.preventDefault();
e.stopPropagation();
invalid_help.removeClass('d-none');
form.find(':invalid')
.attr('aria-invalid', true)
.attr('aria-describedby', function() {
return $(this).siblings('.invalid-feedback').attr('id');
});
} else {
sending_help.removeClass('d-none');
}
form.addClass('was-validated');
});
$('.submit-post-incomplete').click(function(e) {
$('.sending_help').removeClass('d-none');
});
});