简体   繁体   English

Rails Gem 客户端验证 html 结构

[英]Rails Gem Client Side Validations html struct

My project use Twitter Bootstrap CSS Framework,so my html like this.我的项目使用 Twitter Bootstrap CSS 框架,所以我的 html 是这样的。

<div class="control-group ">
  <label class="control-label" for="user_name">Username</label> 
  <div class="controls">
    <input data-validate="true" id="user_name" name="user[name]" size="30" type="text">
  </div>
</div>

When validate failed, Client Side Validation change it to:当验证失败时,客户端验证将其更改为:

<div class="control-group ">
  <div class="field_with_errors">
    <label class="control-label" for="user_name">Username</label>
  </div> 
  <div class="controls">
    <div class="field_with_errors">
      <input data-validate="true" id="user_name" name="user[name]" size="30" type="text">
      <label for="user_name" class="message">Please input Username</label>
    </div>
  </div>
</div>

But I want to user Bootstrap Form validation Css: The html is:但我想用户 Bootstrap 表单验证 Css: html 是:

<div class="control-group error">
   <label class="control-label" for="inputError">Input with error</label>
   <div class="controls">
      <input type="text" id="inputError">
         <span class="help-inline">Please correct the error</span>
      </div>
   </div>
</div>

How to do?怎么做?

try this gem: realtime validations试试这个 gem:实时验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM