[Javascript] If else statement help
Simeon Willbanks
simeon at simeons.net
Thu Oct 2 10:30:10 CDT 2003
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);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20031002/1c0d8d9f/attachment.htm>
More information about the Javascript
mailing list