2

I have a Symfony2 form with an input "text" field that I hide with jQuery to use an autocomplete field in its place (the css of the input field is set to: "display: none"). Given that the field is required, when I try to submit the form without making a selection, I get a validation error message as expected. However, the problem I'm running into is that the HTML5 client-side validation error shows up (bubbles up) outside of the browser's window (attached to the lower left corner), instead of where the autocomplete field is located. That happens because the input field that sets the position of the error bubble is hidden.

Is there a simple way to attach the error bubble (from HTML5 form validation) to another element so that it shows up in the correct position? Perhaps attach it to the input field's label instead of the widget? or to the "ul" element created with the jQuery plugin? To give a little context, I'm using the Loopj Tokeninput jQuery plugin, that creates a "ul" element in place of the form's input "text" field (setting the style of the latter to "display: none").

RayOnAir
  • 2,038
  • 2
  • 22
  • 33
  • Do you mean that the HTML5 Client-Side validation doesn't show, or the form errors generated by symfony? – Thomas K Aug 21 '12 at 06:20
  • I think its about the HTML5 Client-Side validation error. It bubbles up when attempting to send the form with the required input field blank. – RayOnAir Aug 21 '12 at 13:11

1 Answers1

0

This is not Symfony related, but related to HTML5 client side validation.

You can specify the novalidate attribute on the form to turn off clientside validation for the whole form and roll your own validation error:

<form method="post" action="/foo" novalidate></form>

See this question for other options: Disable validation of HTML5 form elements

Community
  • 1
  • 1
Thomas K
  • 6,076
  • 5
  • 39
  • 56
  • Thanks for the input @thomas-k. I have revised my question a bit based on it. I would still like to explore how to re-position the HTML5 client side validation message (if at all possible) since that would save me some work (I'm not sure I need to have my own validation, and its better for me to have it on the client)... – RayOnAir Aug 21 '12 at 15:59