4

im trying to get jquery validation to my symfony 2 project for long time. It work fine with default messages. But cant get there custom messages. There is problem with name of inputs. When i try something like this:

rules: {
   xxx_backbundle_offerstype[title]: "required"
},messages: {
   xxx_backbundle_offerstype[title]: "This field is required"
}

I get this error "missing operator after id". I think, it is JS error, but i dont know, how to solve it. Is it actually possible, to use jquery validation inf symfony.

Thank you for any tips

2 Answers 2

3

try below, use single quotes

rules: {
   'xxx_backbundle_offerstype[title]': "required"
},messages: {
   'xxx_backbundle_offerstype[title]': "This field is required"
}
Sign up to request clarification or add additional context in comments.

Comments

2

If you embed your JavaScript in HTML, you could do this (at least I'm doing it this way):

rules: {
    '{{ form.foo.vars.full_name }}': 'required'
},
messages: {
    '{{ form.foo.vars.full_name }}': 'This field is required!'
}

By doing this, you won't have to update your script when you update your form item's name.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.