比如说我三个文本框,两个radio
1文本框
2文本框
3文本框
4radio
5radio
当我选中4,1必须填写内容
当我选中5,2必须填写内容
用JS做法

解决方案 »

  1.   

    <html>
    <head>
    <script>
    function a(){
    if(document.getElementById('rad1').checked){
    alert('1必须输入')
    }
    if(document.getElementById('rad2').checked){
    alert('2必须输入')
    }
    }
    </script>
    </head>
    <body>
    <form name='form1'>
    1<input id='txt1'/></br>
    2<input id='txt2'/></br>
    3<input id='txt3'/></br>
    <input type=radio id='rad1' name='rad'/>
    <input type=radio id='rad2' name='rad'/>
    </br>
    <input type='button' onclick='a()'/>
    </form>
    </body>
    </html>
      

  2.   

    兄台你这判断当单击rad1的时候,光提示了啊,用户单击一下就过去了吧,不受限制啊
      

  3.   

    晕,有思路还不行吗function a(){
        if(document.getElementById('rad1').checked){
            alert('1必须输入');
            return;
        }
        if(document.getElementById('rad2').checked){
            alert('2必须输入')
            return;
        }
    }
      

  4.   

    if(radio1.checked){
             if(linkform.name == ""){
               alert("请输入连接名称");
             }
           }
           if(radio2.checked){
             if(linkform.image == ""){
               alert("请输入图片地址!");
             }
    要思路我这比你的还明了呢
      

  5.   

    function click(){
        if(document.getElementById('radio1').checked){
           alert('1必须输入')
           document.getElementById('input1').focus();
           return;
        }
        if(document.getElementById('radio2').checked){
            alert('2必须输入')
            document.getElementById('input2').focus();
            return;
        }
    }
    <body>
    <form name='form1'>
    1<input type='text' id='input1'/></br>
    2<input type='text' id='input2'/></br>
    3<input type='text' id='input3'/></br>
    <input type=radio id='radio1'name='rad'/>
    <input type=radio id='radio2'name='rad'/>
    </br>
    <input type='button' onclick='click()'/>
    </form>
    </body>