AMP will start supporting forms - see #3343, filing this to get discussion going and to start on the validator part in parallel.
form
, input
, textarea
, select
, option
tags in AMP Docs.<input type=submit>
<input type=”file|password|image|button”>
are invalidaction-xhr
- Optional - to enable a submission flow through XHR. Also has same validation as action
attr (absolute, non-cdn link and https) except not required.cc/ @powdercloud @Gregable @rudygalfi
This would be good to discuss if we can do this behind the experiment in validator.
@powdercloud when can we get this into the validator?
@powdercloud any update on when can we get the validation stuff in for forms?
How important is the "at least one <input type=submit>
child" constraint. We noticed that forms could be submitted even without a submit button, such as a text input field and pressing <enter>
.
Not very important. This was mainly trying to make sure publishers include a submit button (specially on mobile). We can do with runtime error or warning for now.
Are all other* input attributes optional?
What about textarea, select and option?
*everything except type=”file|password|image|button”
I noticed in the amp-form documentation that the example includes fieldset
and label
. We currently do not allow these. Are we intending to allow them here only as children of form
and only if amp-form
extension is included?
Added fieldset
and label
as required children of form
and only if amp-form
extension is included.
Added all attributes for input
except type="file|password|image|button" and those related to type="image" such as "src" and "usemap". Added all attributes for textarea
, select
and option
. Let me know if we should exclude any others.
Resolved, but still waiting to deploy to cdn.ampproject.org.
Thanks so much!
Added fieldset and label as required children of form
This doesn't mean that publishers have to have label and fieldset inside form? It only means that if they use them in their AMP Doc they must be a descendant of form, right?
Yes, that's correct. If label
or fieldset
appear in the doc, then they must be a descendant of form
and also include the amp-form extension script.
This has now been deployed everywhere.
@mkhatib Why are <input type="password">
and <input type="button">
not allowed in AMP? How can I make a login form or add any buttons except for submit/reset? Please reconsider allowing them.
Most helpful comment
@mkhatib Why are
<input type="password">
and<input type="button">
not allowed in AMP? How can I make a login form or add any buttons except for submit/reset? Please reconsider allowing them.