【问题标题】:jquery validate plugin method/css issue..need helpjquery 验证插件方法/css 问题..需要帮助
【发布时间】:2010-01-06 19:55:37
【问题描述】:
我有一个简单的表单,当字段无效时会出现一些 CSS 问题。
检查一下:
Simple Form with jQuery and Validate plugin
所以所有字段都是必需的。如果您只是点击提交按钮,错误字段会以漂亮的黄色背景提醒您(以及无效文本)。
问题在于选项按钮。单选按钮周围的 div 没有黄色背景。但是,得到这个。在“amountOther”字段中键入除#'s 以外的任何内容,黄色高亮显示。这让我很困惑。为什么它不会在第一次尝试时突出显示?
想法?
谢谢!
【问题讨论】:
标签:
jquery
forms
jquery-validate
【解决方案1】:
将AmountOther 文本框移动到自己的<div class="field">
<div class="field" id="radioButtons">
<label>Please select a donation amount or enter the amount you would like to donate below.</label>
<div class="option">
<input name="Amount" type="radio" id="amount25" value="25" class="radio" />
<label for="amount25">$25</label>
</div>
<div class="option">
<input name="Amount" type="radio" id="amount50" value="50" class="radio" />
<label for="amount50">$50 <span>most popular amount</span></label>
</div>
<div class="option">
<input name="Amount" type="radio" id="amount100" value="100" class="radio" />
<label for="amount100">$100</label>
</div>
<div class="option">
<input name="Amount" type="radio" id="amount250" value="250" class="radio" />
<label for="amount250">$250</label>
</div>
<div class="option">
<input name="Amount" type="radio" id="other" value="other" class="radio" />
<label for="other">other <span>(minimum $1 donation)</span></label>
</div>
<div id="donationErrorMsg"></div>
</div>
<div class="field">
<input type="text" class="textbox" name="AmountOther" id="AmountOther" value="" />.00
</div>
包含单选按钮的div 未突出显示,因为相同的div 包含AmountOther 文本字段(如果未选择其他单选按钮则不需要)。在同一个 div 中有两个字段(Amount 和 AmountOther),一个是必需的(Amount),一个不是(AmountOther),因为它没有突出显示。