5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-29 18:26:22 +00:00
panel/app/assets/javascripts/validation.js

38 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2018-06-15 22:13:18 +00:00
$(document).on('turbolinks:load', function() {
2018-06-25 20:36:10 +00:00
// Al enviar el formulario del artículo, aplicar la validación
2018-07-23 14:26:40 +00:00
$('.submit-post').click(function(e) {
2018-06-15 22:13:18 +00:00
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');
});
2018-06-15 22:13:18 +00:00
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');
2018-06-15 22:13:18 +00:00
}
form.addClass('was-validated');
});
2018-12-14 15:12:17 +00:00
$('.submit-post-incomplete').click(function(e) {
$('.sending_help').removeClass('d-none');
});
2018-06-15 22:13:18 +00:00
});