【发布时间】:2014-03-15 09:39:45
【问题描述】:
我设法做复选框列表,使下拉选项在单击复选框时显示和隐藏,当我不选中任何复选框时,基本下拉选项将仅显示,并且需要选择这些下拉选项在点击提交之前。
问题是当任何一个复选框被选中时,基本的下拉选项会被隐藏,而其他下拉选项会显示,但是当点击提交按钮时,浏览器外的消息 pupup 显示仍然需要字段,这些字段是隐藏的下拉选项。
我想让这些下拉选项在隐藏时不需要。
这里是复选框的代码:
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j(':checkbox').bind('change', function() {
var thisClass = $j(this).attr('class');
if ($j(this).attr('checked')) {
$j(':checkbox.' + thisClass + ":not(#" + this.id + ")").removeAttr('checked');
}
else {
$j(this).attr('checked', false);
$j('.main-options').show();
$j('.first-image').show();
$j('.hide-onload').hide();
}
});
});
这是显示/隐藏的代码:
$j(document).ready(function(e) {
$j('.roundedOne').each(function(index, element) {
$j(this).click(function(){
$j('.main-options').hide();
$j('.first-image').hide();
$j('.hide-onload').hide();
$j('.changing-options').eq(index).show();
$j('.changing-image').eq(index).show();
});
});
});
我希望我是清楚的。
【问题讨论】:
-
你在使用 jqueryvalidation 吗?
-
如果你使用 jqueryvalidation 你可以使用忽略属性,请检查forum.jquery.com/topic/…
-
实际上,我正在使用 Magento 验证,但我在主联系表单中添加了新字段,其中包含 jquery 内容,因此现在混合在一起,我仅在需要某些内容时才使用“required”属性。这是页面的链接:cabas-durables.fr/magento/index.php/contacts 仍在处理中。
标签: jquery drop-down-menu required