469,325 Members | 1,602 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

two forms in 1 validation

3
Hi!

I'm quite new with this web development. I have a problem to validate a form that if the user selected 'other' in the dropdown list, they need to key in something in another text field form. Here's my javascript:

if (theForm.University1a.value == "Other" *can we put something here?* theForm.University1.value == "")
{
alert("You have selected Other. Please enter a value for the \"University\" field.");
theForm.University1.focus();
return (false);
}

Thanks in advance!
Mar 27 '08 #1
6 887
aswath
18
Hi!

I'm quite new with this web development. I have a problem to validate a form that if the user selected 'other' in the dropdown list, they need to key in something in another text field form. Here's my javascript:

if (theForm.University1a.value == "Other" *can we put something here?* theForm.University1.value == "")
{
alert("You have selected Other. Please enter a value for the \"University\" field.");
theForm.University1.focus();
return (false);
}

Thanks in advance!
if the user choose others, he must be shown a textbox where he can enter his choice.. is that what u r asking dude.....
regards
Mar 27 '08 #2
firdzz
3
if the user choose others, he must be shown a textbox where he can enter his choice.. is that what u r asking dude.....
regards
nope. what i mean is when the user submit the form, the javascript will check if the user have selected other, they must key in something in the textbox and cannot be blank. I'm not sure what to put to replace the comma (,) since it is not checking the blank textbox.


if (theForm.University1a.value == "Other" , theForm.University1.value == "")
{
alert("You have selected Other. Please enter a value for the \"University\" field.");
theForm.University1.focus();
return (false);
}
Mar 27 '08 #3
r035198x
13,262 8TB
nope. what i mean is when the user submit the form, the javascript will check if the user have selected other, they must key in something in the textbox and cannot be blank. I'm not sure what to put to replace the comma (,) since it is not checking the blank textbox.


if (theForm.University1a.value == "Other" , theForm.University1.value == "")
{
alert("You have selected Other. Please enter a value for the \"University\" field.");
theForm.University1.focus();
return (false);
}
Perhaps you are looking for && (and)?

Expand|Select|Wrap|Line Numbers
  1. if (theForm.University1a.value == "Other" && theForm.University1.value == "")
Mar 27 '08 #4
vee10
141 100+
Hi,
if (theForm.University1a.value == "Other" , theForm.University1.value == "") ',' should be replaced with or condition || since u want the value should not be null or selected other

nope. what i mean is when the user submit the form, the javascript will check if the user have selected other, they must key in something in the textbox and cannot be blank. I'm not sure what to put to replace the comma (,) since it is not checking the blank textbox.


if (theForm.University1a.value == "Other" , theForm.University1.value == "")
{
alert("You have selected Other. Please enter a value for the \"University\" field.");
theForm.University1.focus();
return (false);
}
Mar 27 '08 #5
r035198x
13,262 8TB
Hi,
if (theForm.University1a.value == "Other" , theForm.University1.value == "") ',' should be replaced with or condition || since u want the value should not be null or selected other
If "Other" is selected then there should be a value for University1 as well therefore it's && (see my reply above) that the OP wants.
Mar 27 '08 #6
firdzz
3
If "Other" is selected then there should be a value for University1 as well therefore it's && (see my reply above) that the OP wants.
Thanks it's working =D. Thanks to others also for comments =D
Mar 27 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by GrelEns | last post: by
1 post views Thread by diroddi | last post: by
4 posts views Thread by Kathy | last post: by
3 posts views Thread by Earl Teigrob | last post: by
1 post views Thread by russr | last post: by
1 post views Thread by mehdi | last post: by
1 post views Thread by Sergei Riaguzov | last post: by
4 posts views Thread by jehugaleahsa | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.