fix: focus invalid field on error in article form
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user