[Javascript] If else statement help
Chris Tifer
christ at saeweb.com
Thu Oct 2 10:34:44 CDT 2003
If else statement helpThat way works, but case statements might be easier.
What I think you might be messing up on is in your form declaration, I'm assuming you have an onsubmit event fired that calls this function, right? Make sure it's:
onsubmit="return functionName()"
Chris Tifer
http://micclub.net
----- Original Message -----
From: Simeon Willbanks
To: javascript at latech.edu
Sent: Thursday, October 02, 2003 11:30 AM
Subject: [Javascript] If else statement help
Hello All,
I am trying to get a form to submit if a text box has a value of 4,5, or 8 characters. If the box has any other value, the script continues on to validate other form values. My current code is below.
If I take away the or value=5 and or value=8, the form will submit if 4 characters are in the box. It will not submit if any other number of characters are in the box. When the code is used in it's current state, the form will submit no matter how many characters are in the box. What is the proper way to ask if a box value is equal to 4,5, or 8 please submit?
Thanks,
Simeon
if (theForm.rn.value.length == 4) || (theForm.rn.value.length == 5) || (theForm.rn.value.length == 8) {return (true);}
else
{
alert("Please enter a \"First name\".");
theForm.dafn.focus();
return (false);
}
------------------------------------------------------------------------------
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20031002/8f326807/attachment.htm>
More information about the Javascript
mailing list