Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome Email Input Field built-in validation warning visually offset
    primarykey
    data
    text
    <p>I'm building a super-simple sign-up form for a mini app and thought it'd be fun to use the browser's built-in HTML5 validations if I could - so I made the text input for the form a <code>type="email"</code> for funsies. Load it up in Chrome (27.0.1453.116) and attempted to enter an invalid email ("lksjdf" or something, you know), and as expected an error message pops up when I attempt to submit. But the unexpected part was the validation message is offset from the text box by about 60 pixels (give or take a few)(note that the email field is active, but the error message appears to point to the password field):</p> <p><img src="https://i.stack.imgur.com/RJAIr.png" alt="screenshot of strange validation error"></p> <p>If I remove all styling and just leave the markup, the validation message position is improved, but about the amount of margin and padding that were on the form field:</p> <p><img src="https://i.stack.imgur.com/x9dy0.png" alt="second screenshot"></p> <p>When I repeat the process in Firefox, the validations show up correctly.</p> <p>As we're narrowing down the issue, it appears that having an <code>&lt;h1&gt;</code> tag just before the form tag causes the problem to appear - if I remove the <code>&lt;h1&gt;</code> tag then the validation message lines up correctly.</p> <p>Is this a bug in Chrome? Is there a way I can force Chrome's validation messages to line up with the input correctly? Why would another tag cause it to not line up?</p> <p>Here's the code so you can test/verify:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Sample App | Sign Up&lt;/title&gt; &lt;!-- stripped out styles and js --&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- stripped out other irrelevant markup --&gt; &lt;h1&gt;Sign Up&lt;/h1&gt; &lt;form accept-charset="UTF-8" action="" id="new_user" method="post"&gt; &lt;label for="user_name"&gt;Name&lt;/label&gt; &lt;input id="user_name" name="user[name]" size="30" type="text" /&gt; &lt;label for="user_email"&gt;Email&lt;/label&gt; &lt;!-- This is the validation test field! --&gt; &lt;input id="user_email" name="user[email]" size="30" type="email" /&gt; &lt;label for="user_password"&gt;Password&lt;/label&gt; &lt;input id="user_password" name="user[password]" size="30" type="password" /&gt; &lt;label for="user_password_confirmation"&gt;Confirm Password&lt;/label&gt; &lt;input id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password" /&gt; &lt;input class="btn btn-large btn-primary" name="commit" type="submit" value="Create my account" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload