本文介绍了验证嵌套的datalist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script language="javascript" type="text/javascript">
function Validate(source, args) {
var why;
why = "";
// for (var i = 1; i <= parseInt(document.getElementById('<%= dlDirectors.ClientID %>" + cntl + "_ddlDirectors').value); i++) {
for (var i = 1; i <= 10; i++) {
cntl = "";
if (i < 10) {
cntl = "_ctl0" + i;
}
else {
cntl = "_ctl" + i;
}
var numclasseschanged = "<%= dlDirectors.ClientID %>" + cntl + "_ddlDirectors"
// alert(document.getElementById(numclasseschanged).value)
for (var m = 1; m <= parseInt(document.getElementById(numclasseschanged).value); m++) {
cnt2 = "";
if (m < 10) {
cnt2 = "_ctl0" + m;
}
else {
cnt2 = "_ctl" + m;
}
var surname = "<%= dlDirectors.ClientID %>" + cntl + "_DataList1" + cnt2 + "_director_surname"
var givenname = "<%= dlDirectors.ClientID %>" + cntl + "_DataList1" + cnt2 + "_director_givenname"
var howrelated = "<%= dlDirectors.ClientID %>" + cntl + "_DataList1" + cnt2 + "_director_howrelated"
var perbenifit = "<%= dlDirectors.ClientID %>" + cntl + "_DataList1" + cnt2 + "_director_percentofbenifit"
why += checkText(document.getElementById(surname))
why += checkText(document.getElementById(givenname))
why += checkText(document.getElementById(howrelated))
why += checkText(document.getElementById(perbenifit))
}
}
if (why != "") {
alert("Please enter the fields marked in pink !");
return args.IsValid = false;
}
}
</script>
推荐答案
这篇关于验证嵌套的datalist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!