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

How to check for existance of Input elements that are type=TEXT???

Sorry this is a bit of a repost because I wasn't quite accurate in my
original.

I have an hmtl page with a function to see if there are any input
type=text
boxes. If so, that means a user did not complete them (once entered,
my xsl stylesheet makes them text instead of text input boxes, so
there should be NO input text boxes when the user is clicking the
FINISH
button. I have the following which checks for just INPUT, but how to
specify type=text?

Thanks. Kathy

function CheckInput()
{
var cnAll = document.all;
for (var i=0;i<cnAll.length;i++)
{
if(cnAll(i).tagName=='INPUT')
{
alert("You must first complete and SAVE all user inputs!");
return false; }
}
}

HTML snippet:

<form action="Hidden_Birth2.aspx" method="post" onsubmit="return
CheckInput();">
<input type="Submit" name="finish" value="FINISH">
<b>Click the FINISH button when work instruction is complete.</b>
</form>
Jul 20 '05 #1
4 4387
i thought you could also use .type, but you first have to check wether it
isn't null

if (item.type != null)
{
if (item.type == "text")
{
[code goes here]
}
}

"KathyB" <Ka**********@attbi.com> wrote in message
news:75**************************@posting.google.c om...
Sorry this is a bit of a repost because I wasn't quite accurate in my
original.

I have an hmtl page with a function to see if there are any input
type=text
boxes. If so, that means a user did not complete them (once entered,
my xsl stylesheet makes them text instead of text input boxes, so
there should be NO input text boxes when the user is clicking the
FINISH
button. I have the following which checks for just INPUT, but how to
specify type=text?

Thanks. Kathy

function CheckInput()
{
var cnAll = document.all;
for (var i=0;i<cnAll.length;i++)
{
if(cnAll(i).tagName=='INPUT')
{
alert("You must first complete and SAVE all user inputs!");
return false; }
}
}

HTML snippet:

<form action="Hidden_Birth2.aspx" method="post" onsubmit="return
CheckInput();">
<input type="Submit" name="finish" value="FINISH">
<b>Click the FINISH button when work instruction is complete.</b>
</form>

Jul 20 '05 #2
Ka**********@attbi.com (KathyB) wrote in message news:<75**************************@posting.google. com>...
Sorry this is a bit of a repost because I wasn't quite accurate in my
original.

I have an hmtl page with a function to see if there are any input
type=text
boxes. If so, that means a user did not complete them (once entered,
my xsl stylesheet makes them text instead of text input boxes, so
there should be NO input text boxes when the user is clicking the
FINISH
button. I have the following which checks for just INPUT, but how to
specify type=text?

Thanks. Kathy

function CheckInput()
{
var cnAll = document.all;
for (var i=0;i<cnAll.length;i++)
{
if(cnAll(i).tagName=='INPUT')
{
alert("You must first complete and SAVE all user inputs!");
return false; }
}
}

HTML snippet:

<form action="Hidden_Birth2.aspx" method="post" onsubmit="return
CheckInput();">
<input type="Submit" name="finish" value="FINISH">
<b>Click the FINISH button when work instruction is complete.</b>
</form>


I'm no expert, but I'd think that you could check the type property of
the input objects.

By the way, wouldn't using document.getElementsByTagName('input') to
return the inputs easier than iterating through the all collection?

How does your style sheet change the inputs to text?

Just wondering.

FWIW
Jul 20 '05 #3
gd*******@hotmail.com (Greg) writes:
By the way, wouldn't using document.getElementsByTagName('input') to
return the inputs easier than iterating through the all collection?


Absolutely. And more portable.
And even if one wants to use document.all, it is still faster to
use document.all.tags("input").

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
In my html, there are only a small number (if any) of text inputs
(mostly a procedure document). Each input already has a SAVE box that
runs its own validation and save to the DOM on the server.

So then it is time to click FINISH, I just want to look if there are ANY
text inputs (empty or not). If they are not empty, they haven't been
saved yet to the DOM and the user needs to do it correctly, etc.

My xsl for each reload (after a DOM change/save), looks to see if the
text node exists for that element (measure, data, etc.) and if so, just
renders it as text, not an input box.

I need to use document.all because I never know (scriptwise) what my
input elements are named, they change according to the xml content. So
here I'm simply checking for the EXISTANCE of a text type=text. BTW, I
have other "input" elements so I'm just looking for type=text at this
point.

Thanks for the replies. Being fairly new to js, not sure which way I'm
supposed to go now...from your answers!

Please let me know what you think, now that I hope I've clarified?

:-)

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

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

Similar topics

6
by: Walter | last post by:
Hi, The user has to type his name into input a input field (type = text). This name must be passed to another ASP file. I did this but nothing happened: <form id=ins method="post"...
2
by: sebastien | last post by:
Hi, What does this always jumps to another page when I try to asign text in the input type text : titel <form id="formie" name="formie" method="post" action="/staff/news/news.php"> <input...
3
by: Vanitha | last post by:
Hi All, The following syntax is not working on Mozilla browser, however this works on IE. <input id="freq" size="20" name="freq" type="text"> When i refer this freq from a javascript...
12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
2
by: Hoss | last post by:
Hi guys, The framework of my page is an aspx page with a header and a footer. The header is a menu system and depending on what you select there different ascx pages are loaded into the middle...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
11
by: C.W.Holeman II | last post by:
I what to hide an input element and the following text. I have the selector for the input working and just need to grab the text following it. CSS: form{ display:table; text-align:center; }
4
by: backups2007 | last post by:
I want to be able to pass rows of queried data to rows of input text boxes. As the example below shows, I have come up with this incomplete solution. But this code only passes the data to the first...
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
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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,...
0
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...

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.