JSP單選按鈕驗(yàn)證、下拉框驗(yàn)證、復(fù)選框驗(yàn)證實(shí)現(xiàn)代碼
更新時(shí)間:2008年11月14日 23:21:49 作者:
單選按鈕驗(yàn)證、下拉框驗(yàn)證、判斷是否選擇了至少一個(gè)CheckBox
//驗(yàn)證性別(單選按鈕驗(yàn)證)
function checkXb(){
var temp = false;
var xbObj1= document.getElementById("xb1");
var xbObj2= document.getElementById("xb2");
if(xbObj1.checked || xbObj2.checked){
temp = true;
}
return temp;
}
function checkform() {
//驗(yàn)證性別(單選按鈕驗(yàn)證)
if(!checkXb()){
alert("請(qǐng)選擇性別");
return false;
}
//驗(yàn)證人員類(lèi)別(下拉框驗(yàn)證)
if(document.getElementById("lb").selectedIndex == 0){
alert("請(qǐng)選擇人員類(lèi)別");
return false;
}
}
// (復(fù)選框驗(yàn)證)判斷是否選擇了至少一個(gè)CheckBox.
function checkSelectedOne(cbxName){
var cbxs = document.getElementsByName(cbxName);
if(cbxs != null){
if(cbxs.length){
for(var i=0; i<cbxs.length; i++){
if(cbxs[i].checked) {
return true;
}
}
}else{
return cbxs.checked
}
}
return false;
}
if(!checkSelectedOne('xgjzh')){
alert("你沒(méi)有選擇!");
}
function checkXb(){
var temp = false;
var xbObj1= document.getElementById("xb1");
var xbObj2= document.getElementById("xb2");
if(xbObj1.checked || xbObj2.checked){
temp = true;
}
return temp;
}
function checkform() {
//驗(yàn)證性別(單選按鈕驗(yàn)證)
if(!checkXb()){
alert("請(qǐng)選擇性別");
return false;
}
//驗(yàn)證人員類(lèi)別(下拉框驗(yàn)證)
if(document.getElementById("lb").selectedIndex == 0){
alert("請(qǐng)選擇人員類(lèi)別");
return false;
}
}
// (復(fù)選框驗(yàn)證)判斷是否選擇了至少一個(gè)CheckBox.
function checkSelectedOne(cbxName){
var cbxs = document.getElementsByName(cbxName);
if(cbxs != null){
if(cbxs.length){
for(var i=0; i<cbxs.length; i++){
if(cbxs[i].checked) {
return true;
}
}
}else{
return cbxs.checked
}
}
return false;
}
if(!checkSelectedOne('xgjzh')){
alert("你沒(méi)有選擇!");
}
您可能感興趣的文章:
- js獲取單選按鈕的數(shù)據(jù)
- js簡(jiǎn)單獲取表單中單選按鈕值的方法
- Vue.js表單標(biāo)簽中的單選按鈕、復(fù)選按鈕和下拉列表的取值問(wèn)題
- js取消單選按鈕選中示例代碼
- javascript 單選按鈕 單擊選中 雙擊取消選擇實(shí)現(xiàn)代碼
- JavaScript實(shí)現(xiàn)點(diǎn)擊單選按鈕改變輸入框中文本域內(nèi)容的方法
- js使用DOM設(shè)置單選按鈕、復(fù)選框及下拉菜單的方法
- js實(shí)現(xiàn)不提交表單獲取單選按鈕值的方法
- JS獲取下拉框顯示值和判斷單選按鈕的方法
- js布局實(shí)現(xiàn)單選按鈕控件
相關(guān)文章
基于JSP的動(dòng)態(tài)網(wǎng)站開(kāi)發(fā)技術(shù)
基于JSP的動(dòng)態(tài)網(wǎng)站開(kāi)發(fā)技術(shù)...2006-10-10
ssh項(xiàng)目環(huán)境搭建步驟(web項(xiàng)目)
這篇文章主要介紹了ssh項(xiàng)目環(huán)境搭建步驟(web項(xiàng)目),需要的朋友可以參考下2014-05-05
struts2+jsp實(shí)現(xiàn)文件上傳的方法
這篇文章主要介紹了struts2+jsp實(shí)現(xiàn)文件上傳的方法,涉及JSP基于Struts架構(gòu)實(shí)現(xiàn)文件傳輸?shù)耐暾记?具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10
使用JS顯示倒計(jì)時(shí)數(shù)字時(shí)鐘效果
這篇文章主要介紹了JS實(shí)現(xiàn)的網(wǎng)頁(yè)倒計(jì)時(shí)數(shù)字時(shí)鐘效果,是一款非常實(shí)用的javascript倒計(jì)時(shí)特效,具有一定參考借鑒價(jià)值,需要的朋友可以參考下。2016-10-10

