JRS: In article <11*********************@o13g2000cwo.googlegroups. com>,
dated Mon, 24 Oct 2005 09:09:05, seen in news:comp.lang.javascript,
yj****@gmail.com posted :
Here's what needs to be done.
I have a form with email1, email2, email3, email4, and email5.
I need a way to have an alert come up when more than one email field
contains a value. The user can only enter only one email in one of the
input fields.
Let X.email1 be a well-formed way of addressing email1.
Then
with (X) Y = !!email1.value + !!email2.value + ... !!email5.value
seems to count the number of non-empty boxes.
if (Y>1) alert("whoa!") // if at most one must be non-empty.
if (Y!=1) alert("whoa!") // if exactly one must be non-empty.
You can determine the value of the non-empty field by concatenating them
all; but to determine which it is you'll probably have to seek it.
Overall, it might be better to loop through seeking the first and then
continue (or modify the above) to check for any more.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.