mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-29 16:06:23 +00:00
37 lines
1.1 KiB
JavaScript
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');
|
|
});
|
|
});
|