lundi 12 octobre 2015

Laravel, jQuery - return to bracket notation after validation in Laravel (dot to bracket notation in jQuery)

Using Laravel 5.1.

I have request in which I do form input validation. I call the .ajax method and receive the JSON output.

Something like:

{
    "category.subcategory_one" : ["This field must be at least 3 characters long"],
    "category.subcategory_two" : ["This field must be at least 5 characters long"],
    ...
}

However the inputs which are validated look like this

<input name="category[subcategory_one]" >
<input name="category[subcategory_two]" >

But now I can't add a CSS class to the inputs that weren't filled correctly because in my jQuery I have dot notation.

Is there a simple way to convert category.subcategory_one to category[subcategory_one]?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire