Allowing only one field to contain a value

Y

yjc238

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.
 
W

web.dev

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 ?
 
Y

yjc238

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?
 
E

Evertjan.

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(?).
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Mon, 24 Oct 2005 09:09:05, seen in (e-mail address removed) 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top