Search code examples
htmlformsamp-html

AMP Forms - require specific field input


In the absence of captcha support, I'd like an AMP form to have a field that requires a specific text entry.

For example, "what animal says moo" with a text field where the user must type "cow". If anything else is entered, the form does not submit, but if "cow" is entered, it submits.

Can anyone think of a good way to do this, in a way that a bot could not easily spot? The only thing I could think of is using the pattern attribute for the specific word, but wouldn't that be very easy for a bot to match?

Thank you very much in advance for any ideas. And if you have any suggestions other than this for a good captcha alternative, I'd welcome those, too. (I scoured the forums and support docs, but came up empty.)

Ben


Solution

  • Thank you to Alexander Grosul. See ampproject.org/docs/reference/components/… referenced in his reply, as well as his recommendation for server-side validation. Having read the documentation, I believe the amp-form custom validation will work.