diff --git a/app/assets/javascripts/validation.js b/app/assets/javascripts/validation.js index f05854f6..5a48148f 100644 --- a/app/assets/javascripts/validation.js +++ b/app/assets/javascripts/validation.js @@ -1,11 +1,10 @@ document.addEventListener('turbolinks:load', () => { // Al enviar el formulario del artículo, aplicar la validación // localmente y actualizar los comentarios para lectores de pantalla. - document.querySelectorAll('.submit-post').forEach(submit => { - submit.addEventListener('click', event => { - const form = submit.closest('form') - const invalid_help = form.querySelectorAll('.invalid_help') - const sending_help = form.querySelectorAll('.sending_help') + document.querySelectorAll('form').forEach(form => { + form.addEventListener('submit', event => { + const invalid_help = form.querySelectorAll('.invalid-help') + const sending_help = form.querySelectorAll('.sending-help') invalid_help.forEach(i => i.classList.add('d-none')) sending_help.forEach(i => i.classList.add('d-none')) diff --git a/app/views/posts/_submit.haml b/app/views/posts/_submit.haml index b3879fd5..b21b5ff2 100644 --- a/app/views/posts/_submit.haml +++ b/app/views/posts/_submit.haml @@ -1,6 +1,6 @@ .form-group = submit_tag t('.save'), class: 'btn submit-post' - .invalid_help.alert.alert-danger.d-none + .invalid-help.alert.alert-danger.d-none = site.config.fetch('invalid_help', t('.invalid_help')) - .sending_help.alert.alert-success.d-none + .sending-help.alert.alert-success.d-none = site.config.fetch('sending_help', t('.sending_help'))