使用jQuery进行级联下拉验证
我有两个级联下拉列表。具有值A、B、C的下拉列表1。如果选择A,则在下拉列表2中填充值1、2、3。如果选择B,则填充值6、7、8 要求:我想以这样的方式验证级联下拉列表:如果在下拉列表1中选择了a,并且在下拉列表2中选择了1。这应该是第一次。我可以通过单击“添加”按钮添加新行。当我在下拉列表1中选择一个和在下拉列表2中选择一个时。在提交/保存单击时不应允许。请提供jQuery脚本来验证这一点。提前谢谢 函数验证cascadingdd(){ 调试器使用jQuery进行级联下拉验证,jquery,Jquery,我有两个级联下拉列表。具有值A、B、C的下拉列表1。如果选择A,则在下拉列表2中填充值1、2、3。如果选择B,则填充值6、7、8 要求:我想以这样的方式验证级联下拉列表:如果在下拉列表1中选择了a,并且在下拉列表2中选择了1。这应该是第一次。我可以通过单击“添加”按钮添加新行。当我在下拉列表1中选择一个和在下拉列表2中选择一个时。在提交/保存单击时不应允许。请提供jQuery脚本来验证这一点。提前谢谢 函数验证cascadingdd(){ 调试器 $('select[id^="ddlAp
$('select[id^="ddlApplicableGroup_infrastructure"]').each(
//start outerloop against each element
function (index, element) {
//find all the items again
$('select[id^="ddlProfileName_infrastructure"]').each(
//start inner loop on each item
function (indexInner, elementInner) {
debugger;
if (index != indexInner) {
//compare the items here as they are not the same index numbers so are different elements
//there are different ways to compare, but you could use jquery again for this
//and use the element and elementInner to access each of them.
if ($(element).val() == $(elementInner).val())
alert("2 dd have the same value:" + element.id + ":" + elementInner.id);
}
}
);
}
);
}
您尝试了什么?显示您的代码。$('select[id^=“ddlappablegroup_infrastructure]”)。每个(函数(index,element){$('select[id^=“ddlProfileName_infrastructure]”)。每个(函数(indexInner,elementInner){if(index!=indexInner){if($(element)。val()==$(elementInner)。val())警报(“2 dd具有相同的值:“+element.id+”:”+elementInner.id);}}}};@Napster我有代码要验证具有相同值的下拉列表。但我需要代码段来验证级联下拉列表。