How can I find in JQuery input by name, if I have dot array syntax from Laravel?
Input example:
<input type="text" name="Payments[0][1][Amount]">
<input type="text" name="Reservations[0][Date]">
Laravel validation response from ajax request:
errors: {
Payments.0.1.Amount: "Field is required",
Reservations.0.Date: "Field should be date"
}
Problem: How can I looping through errors array in javascript access input names, if I only have array dot names?
For example, transform Payments.0.1.Amount to Payments[0][1][Amount], or Reservations.0.Date to Reservations[0][Date]
for (const [key, value] of Object.entries(errors)) {
key = somehowParseDotInputToArray(key); // how? :)
$('#app input[name="' + key + '"]').append( '<p class="error">'+ value +'</p>' );
}