2

我正在使用 rails 4 应用程序中的foundation.abide.js,基本代码设置如下。无论我尝试什么或谷歌搜索什么,我似乎都无法确定为什么默认表单总是显示红色错误消息。关于我所缺少的任何想法?

在此处输入图像描述

<div class="row">
  <div class="large-12 columns">
    <h2>Abide</h2>
    <h4 class="subheader">Abide is an HTML5 form validation library that supports the native API by using patterns and required attributes.</h4>

    <form class="custom" data-abide>
      <fieldset>
        <legend>Fieldset</legend>

        <div class="row">
          <div class="large-12 columns">
            <label for="password">Password <small>required</small></label>
            <input type="password" id="password" placeholder="LittleW0men." name="password" required>
            <small class="error" data-error-message>Passwords must be at least 8 characters with 1 capital letter, 1 number, and one special character.</small>
          </div>
        </div>

        <div class="row">
          <div class="large-12 columns">
            <label for="phone">Phone</label>
            <input type="tel" id="phone" placeholder="1 234-567-8910">
            <small class="error" data-error-message>Please enter a properly formatted telephone number.</small>
          </div>
        </div>

        <div class="row">
          <div class="large-4 columns">
            <label for="email">Email</label>
            <input type="email" id="email" placeholder="foundation@zurb.com">
            <small class="error">Valid email required.</small>
          </div>
          <div class="large-4 columns">
            <label for="url">URL <small>required</small></label>
            <input type="url" id="url" placeholder="http://zurb.com" required>
            <small class="error" data-error-message>Valid URL required.</small>
          </div>
          <div class="large-4 columns">
            <div class="row collapse">
              <label for="customDropdown1">Hardest to find in grocery <small>required</small></label>
              <select id="customDropdown1" class="medium" required>
                <option value="">Select grocery item</option>
                <option value="first">Green Chilies</option>
                <option value="second">Raisins</option>
                <option value="third">Panko bread crumbs</option>
                <option value="fourth">Assistance</option>
              </select>
              <small class="error" data-error-message>Broke.</small>
            </div>
          </div>
        </div>

        <div class="row">
          <div class="large-12 columns">
            <hr>
          </div>
        </div>

        <div class="row">
          <div class="large-6 columns">
            <label for="radio1"><input name="radio1" type="radio" id="radio1" required><span class="custom radio"></span> Radio Button 1</label>
            <label for="radio1"><input name="radio1" type="radio" id="radio1" required><span class="custom radio"></span> Radio Button 2</label>
            <label for="radio1"><input name="radio1" type="radio" id="radio1" required><span class="custom radio"></span> Radio Button 3</label>
          </div>
          <div class="large-6 columns">
            <label for="checkbox1"><input type="checkbox" id="checkbox1" style="display: none;" required><span class="custom checkbox"></span> Label for Checkbox</label>
            <label for="checkbox2"><input type="checkbox" id="checkbox2" CHECKED style="display: none;" required><span class="custom checkbox checked"></span> Label for Checkbox</label>
            <label for="checkbox3"><input type="checkbox" CHECKED id="checkbox3" style="display: none;" required><span class="custom checkbox checked"></span> Label for Checkbox</label>
          </div>
        </div>

        <div class="row">
          <div class="large-12 columns">
            <hr>
          </div>
        </div>

        <div class="row">
          <div class="large-12 columns">
            <label for="remarks">Closing Remarks</label>
            <textarea id="remarks" name="remarks" placeholder="Leave your remarks here."></textarea>
          </div>
        </div>

        <div class="row">
          <div class="large-12 columns">
            <button type="submit" class="medium button green">Submit</button>
          </div>
        </div>

      </fieldset>
    </form>

  </div>
</div>
4

1 回答 1

0

仅使用 HTML 片段很难找到问题(看起来没问题,所以问题必须在其他地方)。

你确定:

  • 您包含了 zurb 基础框架中的所有 CSS,并且没有意外覆盖某些 CSS 属性(与 DIV 检查器检查“错误”类确实默认隐藏)
  • 确保您没有尝试在页面加载时发送/验证表单的 JS 片段

如果您想要更详细的分析,请将整个内容发布到某个地方,以便我们可以看到您在那里的完整设置(HTML + CSS + JS)

于 2013-10-29T09:47:32.300 回答