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

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

    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.len gth;i++)
    {
    if(cnAll(i).tag Name=='INPUT')
    {
    alert("You must first complete and SAVE all user inputs!");
    return false; }
    }
    }

    HTML snippet:

    <form action="Hidden_ Birth2.aspx" method="post" onsubmit="retur n
    CheckInput();">
    <input type="Submit" name="finish" value="FINISH">
    <b>Click the FINISH button when work instruction is complete.</b>
    </form>
  • Egbert Beuker

    #2
    Re: How to check for existance of Input elements that are type=TEXT???

    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" <KathyBurke40@a ttbi.com> wrote in message
    news:75e8d381.0 309140637.317cc 4c7@posting.goo gle.com...[color=blue]
    > 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.len gth;i++)
    > {
    > if(cnAll(i).tag Name=='INPUT')
    > {
    > alert("You must first complete and SAVE all user inputs!");
    > return false; }
    > }
    > }
    >
    > HTML snippet:
    >
    > <form action="Hidden_ Birth2.aspx" method="post" onsubmit="retur n
    > CheckInput();">
    > <input type="Submit" name="finish" value="FINISH">
    > <b>Click the FINISH button when work instruction is complete.</b>
    > </form>[/color]


    Comment

    • Greg

      #3
      Re: How to check for existance of Input elements that are type=TEXT???

      KathyBurke40@at tbi.com (KathyB) wrote in message news:<75e8d381. 0309140637.317c c4c7@posting.go ogle.com>...[color=blue]
      > 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.len gth;i++)
      > {
      > if(cnAll(i).tag Name=='INPUT')
      > {
      > alert("You must first complete and SAVE all user inputs!");
      > return false; }
      > }
      > }
      >
      > HTML snippet:
      >
      > <form action="Hidden_ Birth2.aspx" method="post" onsubmit="retur n
      > CheckInput();">
      > <input type="Submit" name="finish" value="FINISH">
      > <b>Click the FINISH button when work instruction is complete.</b>
      > </form>[/color]

      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.getEle mentsByTagName( '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

      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: How to check for existance of Input elements that are type=TEXT???

        gdsafford@hotma il.com (Greg) writes:
        [color=blue]
        > By the way, wouldn't using document.getEle mentsByTagName( 'input') to
        > return the inputs easier than iterating through the all collection?[/color]

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

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Kathy Burke

          #5
          Re: How to check for existance of Input elements that are type=TEXT???

          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!

          Comment

          Working...