下面是JS代码:
1
<
script type
=
"
text/javascript
"
language
=
"
javascript
"
>
2 function CheckDropDownList() {
3 var dropDownList = document.getElementById( " <%=DropDownListID.ClientID %> " ); // 获取DropDownList控件
4 var dropDownListValue = dropDownList.options[dropDownList.selectedIndex].value; // 获取选择项的值
5 // 注:DropDownListID是DropDownList控件的ID。
6
7 // JS验证是否有非0值:
8 if (dropDownListValue == 0 ) {
9 alert( " 请选择……. " );
10 dropDownList.focus();
11 return false ;
12 }
13 else {
14 return true ;
15 }
16 }
17 </ script >
2 function CheckDropDownList() {
3 var dropDownList = document.getElementById( " <%=DropDownListID.ClientID %> " ); // 获取DropDownList控件
4 var dropDownListValue = dropDownList.options[dropDownList.selectedIndex].value; // 获取选择项的值
5 // 注:DropDownListID是DropDownList控件的ID。
6
7 // JS验证是否有非0值:
8 if (dropDownListValue == 0 ) {
9 alert( " 请选择……. " );
10 dropDownList.focus();
11 return false ;
12 }
13 else {
14 return true ;
15 }
16 }
17 </ script >