javascript - Validate Checkbox and Link to New Page(s) -
I am trying to create a form that validates the checkbox I think you have to check the box And then submit before going to a new page. So I have a checkbox, and I have a function to test it, but I can not find it to load the pages. I have two pages here that are saved locally and they are correct, so this verification work There should be a problem with. Any help is appreciated!
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; AcceptTerms & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; You must agree to our terms and conditions before proceeding. & Lt; / H1> & Lt; Br> & Lt; H3 & gt; Do you accept our terms? & Lt; / H3 & gt; & Lt; Form & gt; & Lt; P & gt; & Lt; Input type = "checkbox" name = "checkbox" value = "yes, I accept" /> Yes, I accept & lt; / P & gt; & Lt; Input type = "button" value = "submit" onclick = "confirmTerms ()" & gt; & Lt; / Form & gt; & Lt; Br> & Lt; Button onclick = "openDecline ()" & gt; Rejected Terms & lt; / Button & gt; & Lt; Script & gt; Function openDecline () {window.open ("declinepage.html"); } & Lt; / Script & gt; & Lt; Br> & Lt; Script type = "text / javascript" & gt; Confirm FunctionTerm () {if (document.forms [0] .checkbox.checked == false {Warning ("You did not select a box.") Return return} if (document.forms [0] .checkbox .checked) {Window.location.href = "acceptpage.html";} if (document.forms [0] .checkbox.checked = false) {window.location.href = "declinepage.html";} gt; body & gt; I have made some changes to your script .. I think this is necessary for you and set the ID for your check box
Yes, I accept & lt; / P & gt; & Lt; Input type = "button" value = "submit" nclick = "confirmTerms ()" /> & Lt; / Form & gt; & Lt; Br> & Lt; Button onclick = "openDecline ()" & gt; Rejected Terms & lt; / Button & gt; & Lt; Script & gt; Function openDecline () {window.open ("declinepage.html"); } Confirm the function of the term (if (! (Document.getElementById ("Check 1").) Checked) {Warning ("You have not selected a box."); Details are false;} and {window.location .href = "acceptpage.html";}} function openDecline () {if (! (Document.getElementById ("check1")) checked) {window.location.href = "declinepage.html";}} & Lt ; / Script> gt; & gt; & lt; / html & gt;
here
Comments
Post a Comment