Why doesn't iOS Safari and Chrome scroll the page and show validation message on checkbox and radio input fields?
Asked Answered
T

0

6

Given this example code, why, when submitting the form on iOS Safari/Chrome does the browser not scroll the page to the top and show the validation error on required radio boxes?

This works as expected on the text input field and also on the desktop versions of these browsers and on Android.

If the text padding is removed to shorten the page so that the fields fit within the viewport, the validation message is shown.

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Form Radio Test</title>
</head>

<body>
  <p>iOS Safari/Chrome does not scroll the page/focus on required radio or checkbox input fields when submitting the form. It does however do this on text fields.</p>
  <form>
    <fieldset>
      <legend>Select an option (required)</legend>
      <p>
        <label for="a">A</label>
        <input name="a" type="radio" value="a" id="a" required>
        <label for="b">B</label>
        <input name="a" type="radio" value="b" id="b" required>
      </p>
    </fieldset>
    <fieldset>
      <legend>Enter a value (required)</legend>
      <p>
        <label for="c">C</label>
        <input name="c" type="text" id="c" required>
      </p>
    </fieldset>
    <div id="padding">
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
      <p>Scroll down</p>
    </div>
    <p><button>Submit</button></p>
  </form>
  <p>
    <a href="#" onclick="document.getElementById('padding').style.display='none';return false">Hide padding</a> |
    <a href="#" onclick="document.getElementById('padding').style.display='block';return false">Show padding</a>
  </p>
</body>

</html>

I've reported the bug to Apple via their Safari bug report/feedback page, but I'm not sure if that's the right place to report it.

Tugman answered 28/8, 2018 at 14:46 Comment(7)
Did you find any solution?Mccabe
Nope. Radio silence ;)Tugman
Been a while.. but did you ever find a solution for this?Opportunity
Unfortunately notTugman
I've also been looking for a solution and have shared my current workaround below this question: https://mcmap.net/q/884874/-ios-safari-chrome-won-39-t-scroll-up-to-show-validation-error-message-on-radio-inputCinelli
Can't believe this is still broken in iOS/Safari in 2022. Driving me mad.Verine
Has any body found any updates on this?Machiavellian

© 2022 - 2024 — McMap. All rights reserved.