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

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

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

When the Finish button is clicked, I need to check for any empty input
boxes before loading the next aspx page...but it could be no boxes or
five boxes, etc.?

I've included my html output...if you have any ideas, would greatly
appreciate it.

Thanks, Kathy
*******HTML*********
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<style type="text/css">
bgcolor="#FFFFFF"
h1 {font-family: Gill Sans MT;color: blue;font-size:20pt
font-weight:bold;margin-top:0;margin-bottom:0}
h2 {font-family: Gill Sans MT;color: red;font-size:18pt
font-weight:bold;margin-top:0;margin-bottom:0}
h3 {font-family: Gill Sans MT;color:
white;font-size:14pt;font-weight:bold;margin-top:0;margin-bottom:0}
body {font-family: Gill Sans MT;color: black;font-size:12pt}
p {font-family: Gill Sans MT;color: black;font-size:12pt}
h4 {font-family: Gill Sans MT;color:
white;font-size:12pt;font-weight:bold;text-transform:
uppercase;margin-top:0;margin-bottom:0}
h5 {font-family: Gill Sans MT;color:
white;font-size:12pt;font-weight:bold;margin-top:0;margin-bottom:0}
h6 {font-family: Gill Sans MT;color:
black;font-size:12pt;font-weight:bold;margin-top:0;margin-bottom:0}
</style>
<title>Example of XSLT</title><script language="Javascript">
function Anomaly(typeIn,idIn,textIn)
{
newWindow = window.open(('Anomaly.aspx?type='+typeIn+'&id='+id In+'&text='+textIn),
'Anomaly', 'width=650,height=700,left=100,toolbar=no,menubar= no,resizable=yes');
}
function ValidateSave(formRef,fieldName,min,max)
{
var formField = formRef.elements[fieldName];

if((parseInt(formField.value) != formField.value) ||
formField.value < min || formField.value > max)
{
alert("The entry must be between " +min+ " and " +max+ ".");
formField.focus();
formField.select();
return false;
}
else
{
return confirm("You are about to enter: " +formField.value+ "
-- are you sure?");
}
}
function ConfirmSave(formRef,fieldName)
{
var formField = formRef.elements[fieldName];

if ((formField.value.length==0) || (formField.value==null))
{
alert("You are trying to save a blank entry.");
formField.focus();
formField.select();
return false;
}
else {
return confirm("You are about to enter: " +formField.value+ "
-- are you sure?");
}
}
</script></head>
<body>
<h1>Test Work Instruction One</h1>
<table border="1" width="100%" cellpadding="4">
<tr bgcolor="red" valign="middle">
<th colspan="3" align="left">
<h3>SAFETY</h3>
</th></tr>
<tr>
<td align="center" valign="middle" width="5%"><input style="CURSOR:
HAND" type="button" value="Anomaly"
onclick="javascript:Anomaly('Safety','1','This is the first safety
item, the first item to test the format for the wrap around.')"></td>
<td valign="top"><table border="0"><tr><td align="left"
valign="top">1. *</td>
<td valign="top"><p>This is the first safety item, the first item to
test the format for the wrap around.</p>
</td></tr></table></td>
</tr>
<tr>
<td align="center" valign="middle" width="5%"><input style="CURSOR:
HAND" type="button" value="Anomaly"
onclick="javascript:Anomaly('Safety','2','This is the second safety
item.')"></td>
<td valign="top"><table border="0"><tr><td align="left"
valign="top">2. *</td>
<td valign="top"><p>This is the second safety item.</p>
</td></tr></table></td>
</tr>
</table><br><table border="1" width="100%" cellpadding="4">
<tr bgcolor="orange" valign="middle">
<th colspan="3" align="left">
<h3>TOOLS AND MATERIALS</h3>
</th></tr>
<tr><td colspan="2"><b>Tool/Material</b></td><td
align="center"><b>Jabil Part No.</b></td>
</tr>
<tr><td align="center" valign="middle" width="5%"><input
style="CURSOR: HAND" type="button" value="Anomaly"
onclick="javascript:Anomaly('Tool','part no a','Tool A')"></td>
<td valign="top"><table border="0"><tr><td align="left"
valign="top">1. *</td>
<td valign="top" width="60%">Tool A</td></tr></table></td>
<td valign="top" width="35%">part no a</td>
</tr>
<tr><td align="center" valign="middle" width="5%"><input
style="CURSOR: HAND" type="button" value="Anomaly"
onclick="javascript:Anomaly('Tool','part no b','Tool B')"></td>
<td valign="top"><table border="0"><tr><td align="left"
valign="top">2. *</td>
<td valign="top" width="60%">Tool B</td></tr></table></td>
<td valign="top" width="35%">part no b</td>
</tr>
</table><br><table border="1" width="100%" cellpadding="4">
<tr bgcolor="navy" valign="middle">
<th align="left" colspan="4">
<h3>PROCESS STEPS</h3>
</th>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','1','Step one of the work
instruction.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">**</td>
<td valign="top">1.**</td>
</tr>
</table>
</td>
<td>
<p>Step one of the work instruction.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','2','Step two of the work
instruction.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">**</td>
<td valign="top">2.**</td>
</tr>
</table>
</td>
<td>
<p>Step two of the work instruction.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','2.1','Step two-one goes
here.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="77">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="77">**</td>
<td valign="top">2.1**</td>
</tr>
</table>
</td>
<td>
<p>Step two-one goes here.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','2.2','Step two-two goes
here.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="77">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="77">**</td>
<td valign="top">2.2**</td>
</tr>
</table>
</td>
<td>
<p>Step two-two goes here.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','2.2.1','Step two-two-one
here.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="147">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="147">**</td>
<td valign="top">2.2.1**</td>
</tr>
</table>
</td>
<td>
<p>Step two-two-one here.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','3','Step three of the work
instruction. A test measurement here: ')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">**</td>
<td valign="top">3.**</td>
</tr>
</table>
</td>
<td>
<p>Step three of the work instruction. A test measurement here: <form
name="test_measure" action="ValidateSave.aspx" method="post"
onsubmit="return ValidateSave(this,'test_measure','1','5');"><input
style="CURSOR: HAND" type="text" size="5" name="test_measure"
value="">mm**
<input type="submit" value="SAVE"><input type="hidden"
name="LoRange" value="1" size="10"><input type="hidden" name="HiRange"
value="5" size="10"></form>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','4','Step four of the work
instruction with a test data collection entry: ')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">**</td>
<td valign="top">4.**</td>
</tr>
</table>
</td>
<td>
<p>Step four of the work instruction with a test data collection
entry: <form name="test_data" action="ValidateSave.aspx" method="post"
onsubmit="return ConfirmSave(this,'test_data');"><input style="CURSOR:
HAND" type="text" name="test_data" value="">**
<input type="submit" value="SAVE"></form>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#FFFF99'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="javascript:Anomaly('Step','5','Last step, number
five.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">**</td>
<td valign="top">5.**</td>
</tr>
</table>
</td>
<td>
<p>Last step, number five.</p>
</td>
</tr>
</table>
</td>
</tr>
</tr>
<tr bgcolor="red" valign="middle">
<td align="center" valign="middle"><input type="button" name="Finish"
value="FINISH" onclick="parent.hidden.location='hidden_birth2.asp x?finish=yes'"></td>
<td align="left"><font color="white"><b>Click the FINISH button when
work instruction is complete.</b></font></td></tr>
</table>
</body>
</html>
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <75**************************@posting.google.com >,
Ka**********@attbi.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
-------------------------------------------------
Jul 20 '05 #2

P: n/a
Thanks, Kaeli. Just what I needed.

Kathy

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

P: n/a
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 <in********************@NOSPAMatt.net> wrote in message news:<MP************************@nntp.lucent.com>. ..
In article <75**************************@posting.google.com >,
Ka**********@attbi.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
-------------------------------------------------

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.