textfield maxlength

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smiley22
    New Member
    • Jun 2007
    • 54

    textfield maxlength

    hi guys!! hope you cam help me????

    <input type="text" name="txtSerial No" id= "txtSerialN o" maxlength="20">
    varType = document.crmFor m.txtType.value ;

    if (varType == "SERIAL") {

    document.crmFor m.txtSerialNo.v alue.length = "15";

    } else if (varType == "MIN"){

    document.crmFor m.txtSerialNo.l ength = '10';
    }

    But the txtSerialNo remains in its original length..
    im wat to set the maxlength of the txtSerial defending in the condition in if statement..
    Hope you can help me...thanks!
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by smiley22
    hi guys!! hope you cam help me????

    <input type="text" name="txtSerial No" id= "txtSerialN o" maxlength="20">
    varType = document.crmFor m.txtType.value ;

    if (varType == "SERIAL") {

    document.crmFor m.txtSerialNo.v alue.length = "15";

    } else if (varType == "MIN"){

    document.crmFor m.txtSerialNo.l ength = '10';
    }

    But the txtSerialNo remains in its original length..
    im wat to set the maxlength of the txtSerial defending in the condition in if statement..
    Hope you can help me...thanks!

    Set the maxlength using .....

    [code=javascript]
    document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = ur_choice;
    [/code]

    Try this, i hope it ll help u.
    Best of luck.

    Kind regards,
    Dmjpro.

    Comment

    • smiley22
      New Member
      • Jun 2007
      • 54

      #3
      Originally posted by dmjpro
      Set the maxlength using .....

      [code=javascript]
      document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = ur_choice;
      [/code]

      Try this, i hope it ll help u.
      Best of luck.

      Kind regards,
      Dmjpro.

      document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = "10";


      ouuuuccchhh...i t didn't work :-(

      thanks for the reply...

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by smiley22
        document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = "10";


        ouuuuccchhh...i t didn't work :-(

        thanks for the reply...
        Did u give a space in maxlength.
        Check it.
        Best of luck;

        Kind regards,
        Dmjpro.

        Comment

        • smiley22
          New Member
          • Jun 2007
          • 54

          #5
          Originally posted by dmjpro
          Did u give a space in maxlength.
          Check it.
          Best of luck;

          Kind regards,
          Dmjpro.
          i deleted the space..

          document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = "10";

          wrong number of arguments or invalid property assignment.
          thats my error..

          thanks...

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by smiley22
            i deleted the space..

            document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = "10";

            wrong number of arguments or invalid property assignment.
            thats my error..

            thanks...
            Try it

            [code=javascript]
            document.crmFor m.txtSerialNo.s etAttribute('ma xleng th') = 10;
            [/code]

            Best of luck.

            Kind regards,
            Dmjpro.

            Comment

            • smiley22
              New Member
              • Jun 2007
              • 54

              #7
              Originally posted by dmjpro
              Try it

              [code=javascript]
              document.crmFor m.txtSerialNo.s etAttribute('ma xleng th') = 10;
              [/code]

              Best of luck.

              Kind regards,
              Dmjpro.
              not again,,wrong arguments,. i had tried that a while ago..


              thanks...

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                maxLength has a capital L. See this link. Also, you have been using a string instead of an integer.

                Comment

                • gits
                  Recognized Expert Moderator Expert
                  • May 2007
                  • 5388

                  #9
                  Originally posted by smiley22
                  i deleted the space..

                  document.crmFor m.txtSerialNo.s etAttribute('ma xlength') = "10";

                  wrong number of arguments or invalid property assignment.
                  thats my error..

                  thanks...
                  hi ... the wrong number of arguments are due to the fact that setAttribute() uses 2 arguments ... the name of the attribute, and the value of it to set:



                  [CODE=javascript]node_reference. setAttribute('a ttribute_name', 'attribute_valu e');[/CODE]

                  kind regards ....

                  Comment

                  • iam_clint
                    Recognized Expert Top Contributor
                    • Jul 2006
                    • 1207

                    #10
                    document.crmFor m.txtSerialNo.s etAttribute('ma xlength', 10);

                    Comment

                    • smiley22
                      New Member
                      • Jun 2007
                      • 54

                      #11
                      Originally posted by dmjpro
                      Try it

                      [code=javascript]
                      document.crmFor m.txtSerialNo.s etAttribute('ma xleng th') = 10;
                      [/code]

                      Best of luck.

                      Kind regards,
                      Dmjpro.
                      hey guys!! thanks for your help..i solved my problem already.. this is the code

                      document.crmFor m.txtSerialNo.s etAttribute('ma xLength', '10');

                      thanks for all your help..

                      next time again, hope you find time for me again..

                      best of luck to all!!! :-)

                      Comment

                      • smiley22
                        New Member
                        • Jun 2007
                        • 54

                        #12
                        Originally posted by acoder
                        maxLength has a capital L. See this link. Also, you have been using a string instead of an integer.

                        hey guys!! thanks for your help..i solved my problem already.. this is the code

                        document.crmFor m.txtSerialNo.s etAttribute('ma xLength', '10');

                        thanks for all your help..

                        next time again, hope you find time for me again..

                        best of luck to all!!! :-)

                        Comment

                        • smiley22
                          New Member
                          • Jun 2007
                          • 54

                          #13
                          Originally posted by gits
                          hi ... the wrong number of arguments are due to the fact that setAttribute() uses 2 arguments ... the name of the attribute, and the value of it to set:



                          [CODE=javascript]node_reference. setAttribute('a ttribute_name', 'attribute_valu e');[/CODE]

                          kind regards ....

                          hey guys!! thanks for your help..i solved my problem already.. this is the code

                          document.crmFor m.txtSerialNo.s etAttribute('ma xLength', '10');

                          thanks for all your help..

                          next time again, hope you find time for me again..

                          best of luck to all!!! :-)

                          Comment

                          • smiley22
                            New Member
                            • Jun 2007
                            • 54

                            #14
                            Originally posted by iam_clint
                            document.crmFor m.txtSerialNo.s etAttribute('ma xlength', 10);

                            hey guys!! thanks for your help..i solved my problem already.. this is the code

                            document.crmFor m.txtSerialNo.s etAttribute('ma xLength', '10');

                            thanks for all your help..

                            next time again, hope you find time for me again..

                            best of luck to all!!! :-)

                            Comment

                            • dmjpro
                              Top Contributor
                              • Jan 2007
                              • 2476

                              #15
                              Originally posted by smiley22
                              not again,,wrong arguments,. i had tried that a while ago..


                              thanks...
                              Oppppssss.
                              Sorryyyy ..... what a silly mistake i did.
                              ****.

                              Kind regards,
                              Dmjpro.
                              Last edited by acoder; Jun 12 '07, 11:02 AM. Reason: Just removed something, didn't like it - sorry!

                              Comment

                              Working...