Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 form validation of a checkbox not quite right

View previous topic View next topic Go down 
AuthorMessage
Pothh
Member
Member
Pothh

Posts : 7
Join date : 2011-06-05

form validation of a checkbox not quite right Empty
PostSubject: form validation of a checkbox not quite right   form validation of a checkbox not quite right EmptyFri Jun 17, 2011 2:03 am

confused.

my validation of the clicking on a checkbox doesn't seem to send the value with the form. Should I be adding value='whatever' in the xhtml?

Code:

<form method="post" id='myForm' name='myForm' onsubmit="return checkform(this)" action="/cgi-bin/script/520/9/98">
  <script type='text/javascript'>
//<![CDATA[

      function checkform(form) {
      //validate the terms checkbox
if (!document.myForm.acceptance.checked) { // ! means "not"
    document.getElementById("trmserr").innerHTML = "You must accept the terms and conditions";
    document.getElementById("myForm").acceptance.value = ""; // clear the field
    setTimeout("document.getElementById('myForm').acceptance.focus()", 25); // refocus on it
    return false;
} else {
    document.getElementById("trmserr").innerHTML = "";
}
            
return true;
}

        <span id="trmserr" class='formErrorWarning'></span>
          <p>
            <a class='tooltip' href='#'>
<span class='compulsory'>*</span>
<span class='the_tip'>This is required because, by proceeding, you are accepting these terms and conditions for this purchase. They will be emailed to you along with your order confirmation.</span></a>  <input type="checkbox" id='acceptance' name="acceptance" /> I have read and I accept the terms and conditions.</p>

It works if JS is disabled and it works only sometimes when it is enabled.
Back to top Go down
BaconBitz
Member
Member
BaconBitz

Posts : 4
Join date : 2011-05-11

form validation of a checkbox not quite right Empty
PostSubject: Re: form validation of a checkbox not quite right   form validation of a checkbox not quite right EmptyFri Jun 17, 2011 2:04 am

you've got syntax errors in that code.
Back to top Go down
Pothh
Member
Member
Pothh

Posts : 7
Join date : 2011-06-05

form validation of a checkbox not quite right Empty
PostSubject: Re: form validation of a checkbox not quite right   form validation of a checkbox not quite right EmptyFri Jun 17, 2011 2:06 am

must be a copy and paste thing coz they aren't showing in the error console of FF

it seems to be working now with two lines removed. (thanks lt).
Back to top Go down
Sponsored content




form validation of a checkbox not quite right Empty
PostSubject: Re: form validation of a checkbox not quite right   form validation of a checkbox not quite right Empty

Back to top Go down
 

form validation of a checkbox not quite right

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» Validation
» w3c validation - please help correcting the error
» Integer Arrays, Random Numbers, Try-Catch Validation
» asp.net form
» Validate form

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: form validation of a checkbox not quite right Edit-trash Useless :: Trash-