Open
Description
/resources/views/bootstrap.php
errorPlacement: function (error, element) {
if (element.parent('.input-group').length ||
element.prop('type') === 'checkbox' || element.prop('type') === 'radio') {
error.insertAfter(element.parent());
// else just place the validation message immediately after the input
} else {
error.insertAfter(element);
}
},
replace with
errorPlacement: function(error, element) {
var existingError = element.next('.error-help-block'); // Checking the existence of an already displayed error
if (existingError.length) {
existingError.replaceWith(error); // Replacing an existing error with a new one
} else {
if (element.parent('.input-group').length ||
element.prop('type') === 'checkbox' || element.prop('type') === 'radio') {
error.insertAfter(element.parent());
} else {
error.insertAfter(element);
}
}
},
The form validation is done in php and an error is returned which is inserted like this
@error('username')
<span class="help-block error-help-block">{{ $message }}</span>
@enderror
The problem is that error.insertAfter does not replace this error.
Metadata
Metadata
Assignees
Labels
No labels