<form name="form1" method="post" action="" target="mainFrame" onsubmit="return func()">
function func(){
  var flag="aaaa"
  var a=document.getElementsByName("mobiletelephone")
  for(var i=0;i<a.length;i++){ 
     if(a[i].checked==false){ 
         flag="bbb"
     }
  }
   if(flag=="aaaa"){
 alert("no chekced");
    return false;
       
  }else{
    return true;
  }
}

解决方案 »

  1.   

    function func(){
    var flag="aaaa"
    var a=document.getElementsByName("mobiletelephone")
    for(var i=0;i<a.length;i++){
    if(a[i].checked==true){
    flag="bbb"
    }
    }
    if(flag=="aaaa"){
    alert("no chekced");
    return false;}else{
    return true;
    }
    }
      

  2.   

    <form name=myform action="aaa.aspx">
    <input type="radio" name="mobiletelephone" value="" ID="Radio1">
    <input type="radio" name="mobiletelephone" value="" ID="Radio2">
    <input type="radio" name="mobiletelephone" value="" ID="Radio3">
    <input type="radio" name="mobiletelephone" value="" ID="Radio4">
    </form>
    <input type=submit onclick="return check()" value="submit">
    <script>
    function check()
    {
    var rd = document.getElementsByName("mobiletelephone");
    var  flag = false;
    for(var i=0;i<rd.length;i++)
    {
    if(rd[i].checked) flag = true;
    }
    if(!flag) 
    {
    alert("没选啊")
    return false;
    }
    myform.submit();
    return true;
    }
    </script>
      

  3.   

    朋友那就不要用radio,用checkbox
      

  4.   

    function func(){
    var flag=0
    var a=document.getElementsByName("mobiletelephone")
    for(var i=0;i<a.length;i++){
    if(a[i].checked==true){
    flag=flag+1;
    }
    }
    if(flag=="0"){
    alert("no chekced");
    return false;}else if(flag=="1"){
    alert("no only check 1");
    return false;
    }else{
    return true;
    }
    }
    这只是你的思想的问题
      

  5.   

    form力加个reset不就行了
    <input type=reset value="reset">
      

  6.   

    mingxuan3000(铭轩) 朋友这样不行啊?
    <form name="form1" method="post" action="" target="mainFrame" onsubmit="return func()">
    <input type="checkbox" name="mobiletelephone" value="" ID="Radio1">
    <input type="checkbox" name="mobiletelephone" value="" ID="Radio2">
    <input type="checkbox" name="mobiletelephone" value="" ID="Radio3">
    <input type="checkbox" name="mobiletelephone" value="" ID="Radio4">
    </form>
    <input type=submit  value="submit">
    <script>
    function func(){
    var flag=0
    var a=document.getElementsByName("mobiletelephone")
    for(var i=0;i<a.length;i++){
    if(a[i].checked==true){
    flag=flag+1;
    }
    }
    if(flag=="0"){
    alert("no chekced");
    return false;}else if(flag=="1"){
    alert("no only check 1");
    return false;
    }else{
    return true;
    }
    }
    </script>