[thelist] Javascript conundrum

kristina kristina at kfx-design.co.uk
Thu Jul 5 07:15:34 CDT 2001


Hello group ;o)

i have written the following script, but i can't quite get it to do what i want it to do

if the checkbox is ticked, i would like the email fields to gray out and not be able to be typed in, and for that piece of the script to be ignored as i don't need to make sure the two email address' are the same - and if the checkbox isn't ticked for the two email's to be checked against each other

i can get both things to work seperately but not together

        function validForm(theForm)
          //this gets ticked if the user doesn't have an email address
          if ((!theForm.noemailaddress.checked) && (theForm.email1.value == ""))
          {
            alert("Please enter your email address or check the NO email box");
            theForm.email1.focus();
            return (false);
          }

          return (true);

          //this double checks the email address has been entered the same
          if (theForm.email1.value == "") {
            alert("You must enter a valid email address")
            theForm.email1.focus()
            return false
          }
          if (theForm.email1.value != emailCheck.email2.value) {
            alert("Entered emails did not match")
            theForm.email1.focus()
            theForm.email1.select()
            return false
          }
          return true
        }

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the form
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<form onsubmit="return validForm(this)" method=POST action=someAction.cgi>
<table>
          <tr>
            <td align="right" colspan="4">Please tick here if you do not have an email address:</td>
            <td align="left" colspan="2"><input name="noemailaddress" type="checkbox" value="noemailaddress"></td>
          </tr>
          <tr>
            <td align="right" colspan="3">Email:</td>
            <td align="left" colspan="3"><input name="email1" type="text" size="20"></td>
          </tr>
          <tr>
            <td align="right" colspan="3">Retype Email:</td>
            <td align="left" colspan="3"><input name="email2" type="text" size="20"></td>
          </tr>
</table>
</form>


tia
 kristina

kristina at kfx-design.co.uk





More information about the thelist mailing list