2013-06-25 7 views
-2

이것은 내가 가지고있는 사이트의 양식 하단 부분입니다. TOS 계약 체크 박스를 추가하기 전에 모든 것이 잘 작동했습니다. 이제는 상자가 선택되었는지 여부에 관계없이 사용자에게 상자를 선택해야한다는 경고가 표시됩니다. 어떤 도움이라도 대단히 감사하겠습니다.확인란이 선택되어 있는지 확인합니다.

<input type='checkbox' value='yes' name='tosagree' id='tosagree'> <p>I have read and agree to the privacy policy and terms of use found on this site.</p> 
      <input type='submit' id='submit' name='submit' value='submit'><br /><br /> 
    </form> 
</div> 

<script type='text/javascript'> 
function validateForm() 
{ 
var asking=document.forms["form"]["asaskingprice"].value, 
reasons=document.forms["form"]["asreasons"].value, 
timelines=document.forms["form"]["astimelines"].value, 
sources=document.forms["form"]["assources"].value, 
tos=document.forms["form"]["tosagree"].value; 
if (asking==null || asking=="") 
    { 
    alert("Asking price must be filled out"); 
    return false; 
    } 
if (reasons==null || reasons=="") 
    { 
    alert("reasons must be filled out"); 
    return false; 
    } 
if (timelines==null || timelines=="") 
    { 
    alert("timelines must be filled out"); 
    return false; 
    } 
if (sources==null || sources=="") 
    { 
    alert("sources must be filled out"); 
    return false; 
    } 
if (document.forms["form"]["tosagree"].Checked!=true) 
    { 
    alert("You must agree to the terms of service"); 
    return false; 
    } 
} 
</script> 
+1

권세가 :( –

+0

@JoeFrambach HTTP : //meta.stackexchange합니다. com/a/185105/133242 ...이 문제를 해결하는 방법을 정확히 파악하려고합니다. –

답변

0

당신은과 같이 ID로 날리고을 잡아 수 있습니다 : 너무 현지화 가까운 옵션을 제거 할 수

var tos = document.getElementById('tosagree'); 

if (tos.checked) { 
    //return true 
} 
관련 문제