473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1056
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

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

Similar topics

4
by: GrelEns | last post by:
hello, i have a website to do which will needs many forms, and i'm looking for an elegant way to handle them... i would like to know how do you use php and forms , how do you validate user...
1
by: diroddi | last post by:
How do you validate a SELECT field with m. lemos forms validation class. I want to make sure the user has selected a product and not left the field as the default of 'Select One'. ...
4
by: Kathy | last post by:
I have a form to generate a report. On the form are several textboxes and a "Generate" button. I would like to have the button grayed (not enabled), unless the data in each of the dependant...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
3
by: Earl Teigrob | last post by:
Can a Modal Dialog Box do forms ASP.NET forms validation from within the Modal Box? I want to pop up a dialog box to the user and have it do its own post backs with validation checking and then...
1
by: Kris | last post by:
Hi, I have a DataGrid where in each row has couple of text boxes and an update button. Each row is dynamically generated as the number of rows are not known ahead of time. When the user clicks the...
1
by: russr | last post by:
Hi can anybody help !!! :eek: When i click submit on my web based html form (which uses javascript), i want to automatically add a red asterisk beside the text box of the required fields that...
1
by: mehdi | last post by:
Hi, Consider a dialog that contains some control. You know, the form is validated when every single control in the form is validated successfully. However, if one control tries to cancel the...
1
by: Sergei Riaguzov | last post by:
Hi. I haven't written in PHP too much so I think I should ask how my problem can be solved "the right way". I'm having some forms (actually this is not my code, and actually I haven't got it yet...
4
by: jehugaleahsa | last post by:
Hello: Is it me, or is handling the Validating event for every control on a form extremely annoying? It is especially annoying when my business logic repeats most of the validation. Some things...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.