By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,544 Members | 2,021 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,544 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.