473,396 Members | 2,004 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,396 software developers and data experts.

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 1093
"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.elements[i].name + " is empty!");
return false;
}
}
}
return true;
}
</script>
</head>
<body>
<form action="" method="get" name="form1" onsubmit="return test(this)">
<b>Part Number : </b>
<select name="Part_Number">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Product Description : </b>
<input type="text" name="Product_Description" 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********************@comcast.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.elements[i].name + " is empty!");
return false;
}
}
}
return true;
}
</script>
</head>
<body>
<form action="" method="get" name="form1" onsubmit="return test(this)">
<b>Part Number : </b>
<select name="Part_Number">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Product Description : </b>
<input type="text" name="Product_Description" value="">
<br>
<input type="submit" value="Submit">
<input type="reset">
</body>
</html>

Oct 24 '05 #3
JRS: In article <dj**********@ss405.t-com.hr>, dated Mon, 24 Oct 2005
16:27:32, seen in news:comp.lang.javascript, POLILOP <fmatosic@?.hr>
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.demon.co.uk/js-valid.htm>

--
© 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 25 '05 #4

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

Similar topics

2
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...
0
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 ...
4
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...
5
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...
2
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...
0
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...
5
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...
4
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...
9
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'...
482
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. ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.