HighDots Forums  

Re: Possible to check for empty input boxes when names generated dynamically?

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Possible to check for empty input boxes when names generated dynamically? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kaeli
 
Posts: n/a

Default Re: Possible to check for empty input boxes when names generated dynamically? - 09-12-2003 , 11:39 AM






In article <75e8d381.0309120637.2e8fe4b9 (AT) posting (DOT) google.com>,
KathyBurke40 (AT) attbi (DOT) com enlightened us with...
Quote:
Hi, I'm trying to find a way to validate input text boxes where I
don't know the names until the page is rendered. I've got 2 validate
functions that fire with the onsubmit button of a "mini" form within
the html document.

(substitute your form name in here)


var l = document.formname.elements.length;
for (var i=0; i<l; i++)
{
var e = document.formname.elements[i];
if (e.type=="text")
{
if (isBlank(e))
{
alert("Blank!");
return false;
}
}
}
return true;

function isBlank(strObject)
{
/* Returns false if the field has any non-space characters, true if
not.
You must pass in an input (text) object (not the value) */
var index;
var myChar;

if (! strObject)
{
return true;
}
else
{
var str = strObject.value;
}

for (index = 0; index < str.length; index ++)
{
myChar = str.charAt(index);
if (myChar != " ")
{
return false;
}
}
return true;
}

-------------------------------------------------
~kaeli~
Hey, if you got it flaunt it! If you don't, stare
at someone who does. Just don't lick the TV screen,
it leaves streaks.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------


Reply With Quote
  #2  
Old   
Kathy Burke
 
Posts: n/a

Default Re: Possible to check for empty input boxes when names generated dynamically? - 09-12-2003 , 01:12 PM






Thanks, Kaeli. Just what I needed.

Kathy

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

Reply With Quote
  #3  
Old   
KathyB
 
Posts: n/a

Default Re: Possible to check for empty input boxes when names generated dynamically? - 09-12-2003 , 05:40 PM



Kaeli, I'm trying to modify your code (without success!) to check
document.all instead of a specific form. I now just need to see if any
input type="text" elements exist, not if they're empty. I won't bore
you with what I've tried cause it don't work!

Thanks again for your help.

Kathy
*****************


kaeli <infinite.possibilities (AT) NOSPAMatt (DOT) net> wrote

Quote:
In article <75e8d381.0309120637.2e8fe4b9 (AT) posting (DOT) google.com>,
KathyBurke40 (AT) attbi (DOT) com enlightened us with...
Hi, I'm trying to find a way to validate input text boxes where I
don't know the names until the page is rendered. I've got 2 validate
functions that fire with the onsubmit button of a "mini" form within
the html document.


(substitute your form name in here)


var l = document.formname.elements.length;
for (var i=0; i<l; i++)
{
var e = document.formname.elements[i];
if (e.type=="text")
{
if (isBlank(e))
{
alert("Blank!");
return false;
}
}
}
return true;

function isBlank(strObject)
{
/* Returns false if the field has any non-space characters, true if
not.
You must pass in an input (text) object (not the value) */
var index;
var myChar;

if (! strObject)
{
return true;
}
else
{
var str = strObject.value;
}

for (index = 0; index < str.length; index ++)
{
myChar = str.charAt(index);
if (myChar != " ")
{
return false;
}
}
return true;
}

-------------------------------------------------
~kaeli~
Hey, if you got it flaunt it! If you don't, stare
at someone who does. Just don't lick the TV screen,
it leaves streaks.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.