Search code examples
javascriptvalidationsafariamp-html

AMP form validation for Safari


AMP form only allows me to use HTML5 form validation to validate users inputs. It works well in desktop Chrome browser. But Safari couldn't support HTML5 form validation until now. I found solution, requires external Javascript to implement form validation on Safari browser. But in my case, AMP doesn't allow me to do so.

Is there any hacks or trick to bypass HTML5 validation inputs for Safari?


Solution

  • Try comparing your AMP document to the AMP by Example amp-form demo. The amp-form extension implements a form validation API polyfill for browsers that don't support native validation. If you're using amp-form in Safari versions without native support, the polyfill behavior should run automatically.

    The polyfill validation should look something like this: An example of the amp-form polyfill validation UI. There is a text bubble saying "value missing" pointing to a text field labeled "Name..." above a "Subscribe" button.