高手:如何实现复选框与文本框的复合判断!(速结帖)
高手:我在实现ASP网页数据上传时,一文本框(price)与一复选框组合使用,当复选框没选中时,文本框必须输入内容,请问用JAVASCRIPT如何判断!请高手按我的程序思路解答,或详细解答,速结贴
...
<FORM name= "userinfo " id= "userinfo " method= "post " action= " " onSubmit= "return checkuserinfo(); ">
...
<tr>
<td width= "20% " height= "30 " valign= "middle " align= "center " class= "fon31 "> 产品价格: </td>
<td width= "80% " height= "22 " valign= "middle " align= "left "> <input name= "price " type= "text " class= "regtext3 " size= "40 " maxlength= "20 "> <INPUT name= "prd " id= "prd " type= "checkbox " value= "0 " class= "regtext2 "/> 面议 </td>
</tr>
...
</form>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function checkuserinfo()
...
if(document.userinfo.price.value== " ")&(document.userinfo.prd.checked==false) {
document.userinfo.price.focus();
alert( "对不起,请填写产品生产厂家! ");
return false;
}
...
}
这样调试不正确,请高手指点!
------解决方案-------------------- <SCRIPT LANGUAGE= "JavaScript ">
<!--
function checkuserinfo()
...
if(document.userinfo.price.value== " ")&&(document.userinfo.prd.checked==false) {
document.userinfo.price.focus();
alert( "对不起,请填写产品生产厂家! ");
return false;
}
...
}
------解决方案-------------------- <FORM name= "userinfo " id= "userinfo " method= "post " action= " " onSubmit= "return checkuserinfo
(); ">
<table>
<tr>
<td width= "20% " height= "30 " valign= "middle " align= "center " class= "fon31 "> 产品价格: </td>
<td width= "80% " height= "22 " valign= "middle " align= "left ">
<input name= "price " type= "text " class= "regtext3 " size= "40 " maxlength= "20 ">
<INPUT name= "prd " id= "prd " type= "checkbox " value= "0 " class= "regtext2 "/> 面议 </td>
</tr>
</table>
<INPUT type= "submit " value= "submit ">
</form>
<SCRIPT LANGUAGE= "JavaScript ">
function checkuserinfo()
{
if((document.userinfo.price.value== " ")&&(document.userinfo.prd.checked==true))
{
document.userinfo.price.focus();
alert( "对不起,请填写产品生产厂家! ");
return false;
}
}
</SCRIPT>
复制回去另存为xx.htm,试试