fix: focus invalid field on error in article form

This commit is contained in:
Valentin Lab
2025-10-15 14:49:32 +02:00
parent 858421a9eb
commit a10f0b35d9

View File

@@ -9,14 +9,16 @@
var selector = (typeof(sel) == 'undefined') ? '.save' : sel; var selector = (typeof(sel) == 'undefined') ? '.save' : sel;
$(selector).off().click(function(e) { $(selector).off().click(function(e) {
if (typeof initValidator === 'function') { if (typeof initValidator === 'function') {
console.log('click');
e.preventDefault(); e.preventDefault();
if ($(form).valid()) { if ($(form).valid()) {
$(this).prop("disabled", true); $(this).prop("disabled", true);
$(this).html($(this).data('loading-text')); $(this).html($(this).data('loading-text'));
$(form).submit(); $(form).submit();
} else { } else {
console.log('erreur'); const $firstInvalid = $(form).find(':invalid, .error').first();
if ($firstInvalid.length) {
$firstInvalid.focus();
}
} }
} else { } else {
$(form).submit(); $(form).submit();