469,645 Members | 1,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Allowing only one field to contain a value

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.

Thanks.

Oct 24 '05 #1
5 1057

yj****@gmail.com wrote:
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.

Thanks.


If the user can only enter one email in the form, then is it even
necessary to have email2 - 5 ?

Oct 24 '05 #2
Well email 2 looks into a different field so it's needed since emails
can be stored in different fields.

Any ideas on how to do a check on submit and have an alert?

Oct 24 '05 #3
wrote on 24 okt 2005 in comp.lang.javascript:
Well email 2 looks into a different field so it's needed since emails
can be stored in different fields.

Any ideas on how to do a check on submit and have an alert?


Make one form-input-field and a select or radio-button choice of where to
put it in the database(?).

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #4
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.
Oct 24 '05 #5
Thanks. that's a perfect idea.

Oct 25 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by WindAndWaves | last post: by
1 post views Thread by Don Leverton | last post: by
3 posts views Thread by John young | last post: by
6 posts views Thread by Modest Marsupial | last post: by
3 posts views Thread by tshad | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.