2012-04-07 81 views
0

我的項目使用Twitter Bootstrap CSS框架,所以我的html這樣。Rails Gem客戶端驗證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> 

如果驗證失敗,則客戶端驗證更改爲:

<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> 

但我想用戶引導表單驗證的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> 

怎麼辦?

回答