通用验证
我正在使用 jquery 验证插件。我反复要求在复选框或单选按钮上启用禁用文本框,并且仅在选中时才需要。你能帮我创建一个通用脚本吗?
<table class="list-table">
<tbody>
<tr>
<td width="50"><input type="radio" name="radio2" id="ownAcc" class="required"/></td>
<td width="200">Own Account</td>
<td class="last"><select class="dropdown" id="ownAccDD"><option>Select</option></select></td>
</tr>
<tr class="alt-row">
<td><input type="radio" name="radio2" /></td>
<td>Registered 3rd Party Account</td>
<td class="last"><select class="dropdown"><option>Select</option></select></td>
</tr>
<tr>
<td><input type="radio" name="radio2" id="unreg" /></td>
<td>Unregistered Account</td>
<td class="last"><input type="text" name="uregacc" class="text-box dependent" />
<span class="hintmsg">
(Enter the 13-digit account number)
</span>
</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<span class="hintmsg"><b>Note:</b>Transaction limit is only applicable for registered and unregistered 3rd party account fund transfer.</span>
</td>
</tr>
</tbody>
</table>
I am using jquery validate plugin. I have a repeated requirement of enable disable textbox on on checkbox or radiobutton and only if checked it will be required. Can you help me to create a generic script for the same.
<table class="list-table">
<tbody>
<tr>
<td width="50"><input type="radio" name="radio2" id="ownAcc" class="required"/></td>
<td width="200">Own Account</td>
<td class="last"><select class="dropdown" id="ownAccDD"><option>Select</option></select></td>
</tr>
<tr class="alt-row">
<td><input type="radio" name="radio2" /></td>
<td>Registered 3rd Party Account</td>
<td class="last"><select class="dropdown"><option>Select</option></select></td>
</tr>
<tr>
<td><input type="radio" name="radio2" id="unreg" /></td>
<td>Unregistered Account</td>
<td class="last"><input type="text" name="uregacc" class="text-box dependent" />
<span class="hintmsg">
(Enter the 13-digit account number)
</span>
</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<span class="hintmsg"><b>Note:</b>Transaction limit is only applicable for registered and unregistered 3rd party account fund transfer.</span>
</td>
</tr>
</tbody>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,您可以将自定义验证器添加到您的 jquery 验证插件中,它将根据您的要求工作。
Well in this case you can add a custom validator to your jquery validation plugin which will work according to your requirements.