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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KathyB

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

    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="#FFFFF F"
    h1 {font-family: Gill Sans MT;color: blue;font-size:20pt
    font-weight:bold;mar gin-top:0;margin-bottom:0}
    h2 {font-family: Gill Sans MT;color: red;font-size:18pt
    font-weight:bold;mar gin-top:0;margin-bottom:0}
    h3 {font-family: Gill Sans MT;color:
    white;font-size:14pt;font-weight:bold;mar gin-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;tex t-transform:
    uppercase;margi n-top:0;margin-bottom:0}
    h5 {font-family: Gill Sans MT;color:
    white;font-size:12pt;font-weight:bold;mar gin-top:0;margin-bottom:0}
    h6 {font-family: Gill Sans MT;color:
    black;font-size:12pt;font-weight:bold;mar gin-top:0;margin-bottom:0}
    </style>
    <title>Exampl e of XSLT</title><script language="Javas cript">
    function Anomaly(typeIn, idIn,textIn)
    {
    newWindow = window.open(('A nomaly.aspx?typ e='+typeIn+'&id ='+idIn+'&text= '+textIn),
    'Anomaly', 'width=650,heig ht=700,left=100 ,toolbar=no,men ubar=no,resizab le=yes');
    }
    function ValidateSave(fo rmRef,fieldName ,min,max)
    {
    var formField = formRef.element s[fieldName];

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

    if ((formField.val ue.length==0) || (formField.valu e==null))
    {
    alert("You are trying to save a blank entry.");
    formField.focus ();
    formField.selec t();
    return false;
    }
    else {
    return confirm("You are about to enter: " +formField.valu e+ "
    -- 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%"><inp ut style="CURSOR:
    HAND" type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S afety','1','Thi s is the first safety
    item, the first item to test the format for the wrap around.')"></td>
    <td valign="top"><t able 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%"><inp ut style="CURSOR:
    HAND" type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S afety','2','Thi s is the second safety
    item.')"></td>
    <td valign="top"><t able 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><tabl e 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%"><inp ut
    style="CURSOR: HAND" type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('T ool','part no a','Tool A')"></td>
    <td valign="top"><t able border="0"><tr> <td align="left"
    valign="top">1.  </td>
    <td valign="top" width="60%">Too l A</td></tr></table></td>
    <td valign="top" width="35%">par t no a</td>
    </tr>
    <tr><td align="center" valign="middle" width="5%"><inp ut
    style="CURSOR: HAND" type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('T ool','part no b','Tool B')"></td>
    <td valign="top"><t able border="0"><tr> <td align="left"
    valign="top">2.  </td>
    <td valign="top" width="60%">Too l B</td></tr></table></td>
    <td valign="top" width="35%">par t no b</td>
    </tr>
    </table><br><tabl e border="1" width="100%" cellpadding="4" >
    <tr bgcolor="navy" valign="middle" >
    <th align="left" colspan="4">
    <h3>PROCESS STEPS</h3>
    </th>
    <tr onMouseOver="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','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="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','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="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','2.1','Ste p 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="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','2.2','Ste p 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="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','2.2.1','S tep 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="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','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_meas ure" action="Validat eSave.aspx" method="post"
    onsubmit="retur n ValidateSave(th is,'test_measur e','1','5');">< input
    style="CURSOR: HAND" type="text" size="5" name="test_meas ure"
    value="">mm  
    <input type="submit" value="SAVE"><i nput type="hidden"
    name="LoRange" value="1" size="10"><inpu t type="hidden" name="HiRange"
    value="5" size="10"></form>
    </p>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr onMouseOver="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','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="Validat eSave.aspx" method="post"
    onsubmit="retur n ConfirmSave(thi s,'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="th is.bgColor = '#FFFF99'" onMouseOut="thi s.bgColor =
    '#FFFFFF'">
    <td align="center" valign="middle" ><input style="CURSOR: HAND"
    type="button" value="Anomaly"
    onclick="Javasc ript:Anomaly('S tep','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.locatio n='hidden_birth 2.aspx?finish=y es'"></td>
    <td align="left"><f ont color="white">< b>Click the FINISH button when
    work instruction is complete.</b></font></td></tr>
    </table>
    </body>
    </html>
  • kaeli

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

    In article <75e8d381.03091 20637.2e8fe4b9@ posting.google. com>,
    KathyBurke40@at tbi.com enlightened us with...[color=blue]
    > 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.
    >[/color]

    (substitute your form name in here)


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

    function isBlank(strObje ct)
    {
    /* 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(inde x);
    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.


    -------------------------------------------------

    Comment

    • Kathy Burke

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

      Thanks, Kaeli. Just what I needed.

      Kathy

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

      Comment

      • KathyB

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

        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.possi bilities@NOSPAM att.net> wrote in message news:<MPG.19cba 4b7cc13d7299898 44@nntp.lucent. com>...[color=blue]
        > In article <75e8d381.03091 20637.2e8fe4b9@ posting.google. com>,
        > KathyBurke40@at tbi.com enlightened us with...[color=green]
        > > 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.
        > >[/color]
        >
        > (substitute your form name in here)
        >
        >
        > var l = document.formna me.elements.len gth;
        > for (var i=0; i<l; i++)
        > {
        > var e = document.formna me.elements[i];
        > if (e.type=="text" )
        > {
        > if (isBlank(e))
        > {
        > alert("Blank!") ;
        > return false;
        > }
        > }
        > }
        > return true;
        >
        > function isBlank(strObje ct)
        > {
        > /* 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(inde x);
        > 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
        > -------------------------------------------------[/color]

        Comment

        Working...