2012-05-04 2 views
0

양식을 보내기 위해 사람들이 "이용 약관에 동의합니다"라는 문구가있는 확인란을 선택하게하는 양식을 만들려고합니다.필수 양식을 제출하려면 확인란을 선택하십시오.

이것은 내가 가지고있는 것이지만 양식을 제출하지 않습니다. 오류가 발생합니다. 내가 헤더에 놓여있다

자바 스크립트 :

<script type="text/javascript"> 
    <!-- 

    function validate_form () 
    { 
    valid = true; 

    if (document.form1.cb.checked == false) 
    { 
    alert ("Please check the Terms & Conditions box ."); 
    valid = false; 
    } 

    return valid; 
    } 

    //--> 
    </script> 

형태 : 당신이지고 어떤 다른 오류 <form action="/cgi-bin/FormMail.pl" method="POST" name="frmOne" id="frmOne">

<form action="/cgi-bin/FormMail.pl" method="POST" name="frmOne" id="frmOne" onSubmit="validate_form();">

<form action="/cgi-bin/FormMail.pl" method="POST" name="frmOne" id="frmOne"> 
    <input type=hidden name="recipient" value="[email protected]"/> 
    <table width="100%" cellspacing="5" cellpadding="5" style="margin-top:-20px"> 
    <tr> 
    <td width="50%" valign="top"> 
    <br/> 
     <p><span id="sprytextfield1"> 
    <label for="Full Name">Full Name (First and Last): </label> 
    <input name="Full Name" type="text" id="name" tabindex="10" size="60" /> 
    <span class="textfieldRequiredMsg"><br />Please provide information.</span></span> </p> 
    <p><span id="sprytextfield2"> 
    <label for="Your Email">Your e-mail address: </label> 
    <input name="email" type="text" id="email" size="60" /> 
    <span class="textfieldInvalidFormatMsg"></span></span> </p> 
    <p><span id="sprytextfield3"> 
    <label for="Phone Number"> Phone Number: </label> 
    <input name="Phone Number" type="text" id="phone" size="60" /> 
    <span class="textfieldInvalidFormatMsg"><br />Invalid format.</span><span class="textfieldRequiredMsg"><br/>A phone number is required.</span></span></p> 
    <p class="text"> 
     <span id="sprytextfield4"> 
    <label for="Nature Of The Accident">Nature of Accident, i.e. slip and fall, motor vehicle accident, etc.: </label> 
    <input name="Nature Of The Accident" type="text" id="natureOfAccident" size="60" /> 
    </span></p> 
    <p><span id="sprytextfield5"> 
    <label for="Date Of The Accident">Date of the Accident: </label> 
    <input name="Date Of The Accident" type="text" id="dateOfAccident" size="60" /> 
    <span class="textfieldRequiredMsg"><br />Please provide information.</span><span class="textfieldInvalidFormatMsg"><br />Invalid format.</span></span></p> 
    <p class="text"> 
    </td> 

    <td width="50%" valign="top"> 

    <p class="text"> 
    <span id="sprytextarea1"> 
    <label for="Description Of The Injury"><br />Brief Description of your Injuries: </label> 
    <textarea name="Description Of The Injury" cols="45" rows="4" id="descriptionOfInjury"> 
    </textarea> 
    <span class="textareaRequiredMsg"><br />Please provide information.</span></span></p> 
    <p class="text"> 
    <span id="sprytextarea2"> 
    <label for="Description Of The Accident">Brief Description of the Accident:</label> 
    <textarea name="Description Of The Accident" id="descriptionOfAccident" cols="45" rows="4"></textarea> 
    <span class="textareaRequiredMsg"><br /> 
    Please provide information.</span></span></p> 
    <p class="text"> 
    <span id="sprytextfield6"> 
    <label for="How Did You Hear About Us">How did you hear about us?: </label> 
    <input name="How Did You Hear About Us" type="text" id="howDidYouHear" size="56" /> 
    <span class="textfieldRequiredMsg"><br />Please provide information.</span></span> </p> 
    <input type="checkbox" name="agree" value="agree_terms" id="disclaimer" /> 
    <label for="disclaimer">I have read the Disclaimer</label> 
    <br/><br /> 
    &nbsp;<input type="reset" name="reset" id="reset" value="Reset Form" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    <input type="submit" name="Form Action" id="send" tabindex="100" value="Submit" /> 

    </td> 
    </tr> 
    </table> 

</form> 
<script type="text/javascript"> 
<!-- 
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]}); 
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {validateOn:["blur", "change"], isRequired:false}); 
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "phone_number", {validateOn:["blur"], useCharacterMasking:true}); 
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {isRequired:false, validateOn:["blur", "change"]}); 
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "date", {hint:"dd/mm/yyyy", validateOn:["blur", "change"], format:"dd/mm/yyyy"}); 
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur", "change"]}); 
var sprytextarea2 = new Spry.Widget.ValidationTextarea("sprytextarea2", {validateOn:["blur", "change"]}); 
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "none", {validateOn:["blur", "change"], hint:"Google, etc"}); 
//--> 
</script></div> 
+0

내가'form1'도'cb' 요소도 볼 수 있습니다 도움이되기를 바랍니다. – sp00m

답변

0

변경?

document.getElementById("disclaimer").checked == false로 사용 해보세요 document.form1.cb.checked

+0

변경 사항이 어느 정도 작동하면 양식에 오류가 있다는 내용이 표시되고 면책 조항을 읽었 음을 선택해야합니다. 그러나 확인을 클릭하면 제출을 계속 진행합니다. – Andrew

+0

css-bin/FormMail.pl "method ="POST "name ="frmOne "id ="frmOne "onSubmit ="return validate_form(); "> – Bloafer

0

document.frmOne.agree.checked로 변경합니다.

1

당신이 잘못 형태 및 요소를 참조하고, 이런 식으로 뭔가를 시도 :

<form name="frmOne" method="POST" onSubmit="return checkForm(frmOne);" action="/cgi-bin/FormMail.pl"> 

<script> 
function checkForm(form) 
{ 
    if(!form.agree.checked) 
    { 
     alert("You must agree to this disclaimer before applying."); 
     return false; 
    } 
} 
</script> 

나는 그

관련 문제