When error messages appear in the form, they displace elements to the left. How can this be avoided?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to use a custom error element placement (this would go inside
.validate()) like:This would insert a div containing the error message right before the form element that is generating the error. By altering the 3rd line in the given example, you can move that element wherever you want. For example, based on your code, to move it completely outside the table, you would use:
… and that would place it right before the entire form. Of course, it would be much more elegant to simply designate an error area outside the form …
… and then place the error there:
Depending on which way you decide to go, you might not even need to use
errorElement, but justerrorPlacement. The chosen answer to this question should also give you even more info on how to use it.Hope this helps !
EDIT:
To position the error element to the right, add the error placement code inside
.validate():The generated error element is automatically assigned a class called
.error, so, if needed, you can style with CSS: