首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在AMP中显示验证无效表单消息?

如何在AMP中显示验证无效表单消息?
EN

Stack Overflow用户
提问于 2018-07-13 00:58:23
回答 0查看 900关注 0票数 0

我在一个AMP网站上有一个简单的表单,其中我正在使用as-you-go策略进行字段验证。

我想在submit按钮旁边显示一条通用消息,说明表单仍然无效。

代码语言:javascript
复制
  <form method="POST" class="p2" action-xhr=".../api/contacts" custom- 
      validation-reporting="as-you-go" target="_top">
     <input type="text" placeholder="Email" id="email_input" name="email" 
       required>
     <span visible-when-invalid="valueMissing" validation-for="email_input"></span>
     <input name="phone" id="phone_input" required>
     <span visible-when-invalid="valueMissing"></span>

     //SHOW Invalid form message here!
     <input id="btn-form-submit" type="submit" value="Submit">
      <div id="submit-success" submit-success>
        <template type="amp-mustache">
           <h6>Success!</h6>
        </template>
      </div>
      <div submit-error>
          <template type="amp-mustache">
               <h6> Error</h6>
          </template>
      </div>
    </form>

我想知道是否可以在提交输入旁边显示一条通用错误消息,说明表单仍然无效。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51310993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档