473,549 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get only txt fields

Is there a way to get only the txt fields in my form and check if they are
empty without having to
pass there names or there id's to the function. Something like to pass the
form name and then
get all the text fields from the form and check if they are empty?
Oct 24 '05 #1
3 1100
"POLILOP" <fmatosic@@inet .hr> wrote in message
news:dj******** **@ss405.t-com.hr...
Is there a way to get only the txt fields in my form and check if they are
empty without having to
pass there names or there id's to the function. Something like to pass the
form name and then
get all the text fields from the form and check if they are empty?

Will this help? Watch for word-wrap.

<html>
<head>
<title>formelem .htm</title>
<script type="text/javascript">
function test(form) {
for (var i=0; i<form.elements .length; i++) {
if (form.elements[i].type == "text") {
if (form.elements[i].value == "") {
alert(form.elem ents[i].name + " is empty!");
return false;
}
}
}
return true;
}
</script>
</head>
<body>
<form action="" method="get" name="form1" onsubmit="retur n test(this)">
<b>Part Number : </b>
<select name="Part_Numb er">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Produc t Description : </b>
<input type="text" name="Product_D escription" value="">
<br>
<input type="submit" value="Submit">
<input type="reset">
</body>
</html>
Oct 24 '05 #2
mmm very nice. thank u very much.
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:3p******** ************@co mcast.com...
"POLILOP" <fmatosic@@inet .hr> wrote in message
news:dj******** **@ss405.t-com.hr...
Is there a way to get only the txt fields in my form and check if they
are
empty without having to
pass there names or there id's to the function. Something like to pass
the
form name and then
get all the text fields from the form and check if they are empty?

Will this help? Watch for word-wrap.

<html>
<head>
<title>formelem .htm</title>
<script type="text/javascript">
function test(form) {
for (var i=0; i<form.elements .length; i++) {
if (form.elements[i].type == "text") {
if (form.elements[i].value == "") {
alert(form.elem ents[i].name + " is empty!");
return false;
}
}
}
return true;
}
</script>
</head>
<body>
<form action="" method="get" name="form1" onsubmit="retur n test(this)">
<b>Part Number : </b>
<select name="Part_Numb er">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Produc t Description : </b>
<input type="text" name="Product_D escription" value="">
<br>
<input type="submit" value="Submit">
<input type="reset">
</body>
</html>

Oct 24 '05 #3
JRS: In article <dj**********@s s405.t-com.hr>, dated Mon, 24 Oct 2005
16:27:32, seen in news:comp.lang. javascript, POLILOP <fmatosic@?.h r>
posted :
Is there a way to get only the txt fields in my form and check if they are
empty without having to
pass there names or there id's to the function. Something like to pass the
form name and then
get all the text fields from the form and check if they are empty?


Yes; but unless this is elementary course-work you'd probably do better
to check at least that they have visible contents : /\S/.test(St) should
do that.

<URL:http://www.merlyn.demo n.co.uk/js-valid.htm>

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 25 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1785
by: Tim Cowan | last post by:
Hi I am trying to create a CSV file with some fields in double quotes ("). I am not having any luck. This is what I want; "8684","COSTING","000010001","REG",X4,15.00, ,14,0,14,9,6 I am not sure how to create the double quotes. The ASP is this;
0
1531
by: bill mahoney | last post by:
I have access 2k and I have 2 tables. One is a 7X6 table representing a month with zeroes padding the fields where no day exist. For example February 2003 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 0 0 0 0 0 0 0
4
5998
by: Melissa | last post by:
I have a frontend file named CustomerApp and backend file named CustomerData. CustomerApp is at C:\Customer Database and CustomerData is at S:\Customer Database. Could someone help me with the code to do the following: 1. Create a new table named TblCustomerContact in CustomerData 2. Add a field named CustomerContactID (autonumber) in...
5
10857
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the new database. For instance, her old database has a table with Band Info in it. Her new database also has a table with Band Info in it but slightly...
2
1908
by: Darryl Kerkeslager | last post by:
As the subject above hopefully makes clear, I want to do several reports, "with lots of fields not otherwise in database". These reports also have variable-length text. I have defined the following options (all users have Office 2000): 1. All Access solution. This appears to involve creating forms to enter data that is just put into a...
0
1431
by: Proteus | last post by:
Hi, I'm using access 97 on windows 98. I have table with 162 fields in it. I need to withdraw this information in a (totals) query with 164 fields (162 "avg" fields and 2 "count" fields). When I click from the design to datasheet views, access returns an error message that says "too many fields defined" and an offer for help. Clicking on...
5
14014
by: Genboy | last post by:
My "VIS" Website, which is a C# site created in VS.NET, Framework 1.1, is no longer compiling for me via the command line. As I have done 600 times in the last year and a half, I can compile to VIS.DLL via Visual Studio, with no problems: ------ Rebuild All started: Project: VIS, Configuration: Debug .NET ------ Preparing resources......
4
1850
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
Hey, Well, I have a Problem. I have designed a table which has few fields which are being declared in the database of type .... char of length 10. and other fields with varchar 50 and datetime too. Well, the Problem is I am not able to display the CHAR type FIELDS in the
9
5690
by: sean.scanlon | last post by:
can someone help understand how i can could access a struct field dymanically like: foo->fields ? when i try to compile this i get the following error: 'struct pwd' has no member named 'fields' is there a way to treat fields as the member name of the struct?
482
27364
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my...
0
7472
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7986
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6074
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5391
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3499
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.