本文介绍了JavaScript Asp.net中的复选框列表Validet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript中的用户但不是Validet在JavaScript中如果Eles id else其他条件不起作用



我的Java脚本



i am User in JavaScript But Not Validet In JavaScript if Eles id else Condition not Working

my Java Script

function CheckVal(){
            var objHdnFld = document.getElementById('<%=__SSPLMessageHidden.ClientId%>');

            if(document.getElementById('<%=ddlDesignation.ClientID%>').selectedIndex  == 0)
            {
            alert(GetMsgString(objHdnFld, 'MSG0001', 'Please Select Designation.'));
                return false;
            }
            else if(document.getElementById('<%=chklstWorkwith.ClientID%>').checked == false)
            {
            alert(getMsgString(objHdnFld,'MSG0003','Please Select Position Any One'))
            return false
            }
            else if (document.getElementById('<%=ddlMonth.ClientID%>').selectedIndex  == 0) {
                alert(GetMsgString(objHdnFld, 'MSG0002', 'Please Select Month.'));
                return false;
            }
            else
            {
            return true;
            }
        }











其他Java脚本复选框此处验证脚本





函数ValidateCheckBoxList(){



var listItems = document.getElementById(<%= chklstWorkwith.ClientID%>);

var itemcount = listItems.length;

var iCount = 0;

var isItemSelected = false;

for(iCount = 0; iCount< itemcount; iCount ++)

{

if(listItems [iCount] .checked)

{

isItemSelected = true;

break;

}

}

if(!isItemSelected){

alert(请选择一个位置。) ;

}

else {

返回true;
}

返回false;

}





两者都在同一个按钮中验证点击用户你是procibal






other Java Script Check box Validate here Script


function ValidateCheckBoxList() {

var listItems = document.getElementById("<%=chklstWorkwith.ClientID %>");
var itemcount = listItems.length;
var iCount = 0;
var isItemSelected = false;
for (iCount = 0; iCount < itemcount; iCount++)
{
if (listItems[iCount].checked)
{
isItemSelected = true;
break;
}
}
if (!isItemSelected) {
alert("Please select an Position.");
}
else {
return true;
}
return false;
}


Both Are Validation in Same Button Click user are you procibal

推荐答案

var objHdnFld = document.getElementById('<%=__SSPLMessageHidden.ClientId%>');
function CheckVal(){
    if(document.getElementById('<%=ddlDesignation.ClientID%>').selectedIndex  == 0)
    {
        alert(GetMsgString(objHdnFld, 'MSG0001', 'Please Select Designation.'));
        return false;
    }
    else if(ValidateCheckBoxList() == false)
    {
        return false;
    }
    else if (document.getElementById('<%=ddlMonth.ClientID%>').selectedIndex  == 0)
    {
       alert(GetMsgString(objHdnFld, 'MSG0002', 'Please Select Month.'));
        return false;
    }
    return true;
}
function ValidateCheckBoxList()
{
    var listItems = document.getElementById("<%=chklstWorkwith.ClientID %>");
    var checkBoxes = listItems.getElementsByTagName("input");
    var isItemSelected = false;
    for (var iCount = 0; iCount < checkBoxes.length; iCount++)
    {
        if (checkBoxes[iCount].checked)
        {
            isItemSelected = true;
            break;
        }
    }
    if (!isItemSelected)
    {
        alert(getMsgString(objHdnFld,'MSG0003','Please Select Position Any One'))
        return false;
    }
    return true;
}


这篇关于JavaScript Asp.net中的复选框列表Validet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:02