Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
Show All 30 Lines | error => { | ||||
$.each(error.response.data.errors || {}, (idx, msg) => { | $.each(error.response.data.errors || {}, (idx, msg) => { | ||||
$('form').each((i, form) => { | $('form').each((i, form) => { | ||||
const input_name = ($(form).data('validation-prefix') || '') + idx | const input_name = ($(form).data('validation-prefix') || '') + idx | ||||
const input = $('#' + input_name) | const input = $('#' + input_name) | ||||
if (input.length) { | if (input.length) { | ||||
input.addClass('is-invalid') | input.addClass('is-invalid') | ||||
.parent().append($('<div class="invalid-feedback">') | input.parent().find('.invalid-feedback').remove() | ||||
.text($.type(msg) === 'string' ? msg : msg.join('<br>'))) | input.parent().append($('<div class="invalid-feedback">') | ||||
.text($.type(msg) === 'string' ? msg : msg.join(' '))) | |||||
return false | return false | ||||
} | } | ||||
}); | }); | ||||
}) | }) | ||||
$('form .is-invalid').first().focus() | $('form .is-invalid').first().focus() | ||||
} | } | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |