Limiting Characters in Attribute Text Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GRM
    Mini Mivite

    • Jul 2010
    • 14

    #1

    Limiting Characters in Attribute Text Box

    MM5.5 I need to limit the characters in the text box in product attributes for engraving purposes. Does anyone know if it can be done. I would like to limit it depending on the size selected.
    George
  • alphabet
    Mega Mivite





    • Aug 2006
    • 1160

    #2
    Re: Limiting Characters in Attribute Text Box

    Use the max attribute, for example:

    <input type="text" size="20" max="25">
    http://www.alphabetsigns.com/

    Comment

    • GRM
      Mini Mivite

      • Jul 2010
      • 14

      #3
      Re: Limiting Characters in Attribute Text Box

      I would if I knew where that file is kept. What is the folder and file name for attributes?

      Comment

      • alphabet
        Mega Mivite





        • Aug 2006
        • 1160

        #4
        Re: Limiting Characters in Attribute Text Box

        It most likely is something that you would add to your PAGE > PROD > product attribute template, or to your product template manager. You may need to surround it with conditionals.

        max attribute is for html5, maxlength attribute is for html4.

        Here are some links:



        W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


        Hope this helps,
        http://www.alphabetsigns.com/

        Comment

        • GRM
          Mini Mivite

          • Jul 2010
          • 14

          #5
          Re: Limiting Characters in Attribute Text Box

          I got it to work. I went into Pages - Product Display and then under tab Product Attribute Template.
          I added the bold info below. Which is good but now I have to figure out how to switch it to different lengths when different attributes are selected.
          <mvt:if expr="l.settings:attribute:type EQ 'text'">
          <td align="left" valign="top">
          <mvt:item name="fonts" param="body_font">
          <input type="text" size="20" maxlength="14" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:attribute:value;">
          </mvt:item>
          </td>

          Comment

          • alphabet
            Mega Mivite





            • Aug 2006
            • 1160

            #6
            Re: Limiting Characters in Attribute Text Box

            You can add some javascript that will change the maxlength value onSelect event. Not to difficult.
            http://www.alphabetsigns.com/

            Comment

            • GRM
              Mini Mivite

              • Jul 2010
              • 14

              #7
              Re: Limiting Characters in Attribute Text Box

              Can you give me an example of what it would look like?

              Comment

              • alphabet
                Mega Mivite





                • Aug 2006
                • 1160

                #8
                Re: Limiting Characters in Attribute Text Box

                Something like this but you will have to tweek it to suite your needs:

                Add an id to your input:

                <input type="text" id="embtxt" size="20" maxlength="14" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:attribute:value;">

                Create a function:

                <script type="text/javascript">

                function embLength(embHght,embLngth) {
                getElementById('embtxt').maxlength.value=embLngth;
                }

                </script>

                Call the function on the onSelect event passing the selected height and its maxlength.
                http://www.alphabetsigns.com/

                Comment

                • GRM
                  Mini Mivite

                  • Jul 2010
                  • 14

                  #9
                  Re: Limiting Characters in Attribute Text Box

                  Thanks,
                  I will have to take and study and try to configure out how to get the check boxes attributes to make this work.

                  Comment

                  • alphabet
                    Mega Mivite





                    • Aug 2006
                    • 1160

                    #10
                    Re: Limiting Characters in Attribute Text Box

                    If it's a checkbox add:

                    <input type="checkbox" onClick="embLength(this, 15)">

                    Where the number is the maxlength.
                    http://www.alphabetsigns.com/

                    Comment

                    • GRM
                      Mini Mivite

                      • Jul 2010
                      • 14

                      #11
                      Re: Limiting Characters in Attribute Text Box

                      What if it's multiple checkboxes? How do I separate them?

                      Comment

                      • alphabet
                        Mega Mivite





                        • Aug 2006
                        • 1160

                        #12
                        Re: Limiting Characters in Attribute Text Box

                        Not sure what you mean.

                        If the checkboxes are mutually exclusive then it should be a radio or select input.

                        If the checkboxes have separate text inputs then you would have to give the text inputs separate id's.

                        If you have problems dynamically generating id's and maxlength arguments, then you may need to use an option's weight field in the product > edit > attribute tab > option > weight line.
                        http://www.alphabetsigns.com/

                        Comment

                        • GRM
                          Mini Mivite

                          • Jul 2010
                          • 14

                          #13
                          Re: Limiting Characters in Attribute Text Box

                          I have 8 checkboxes, checking any 4 of the eight would respresent one size and the other 4 would respresent the the other for engraving. This is on 200+ products but with one attribute template. I could have used radio buttons but I chose checkboxes instead.
                          One would allow 14 characters for engraving and the other 12.
                          GRM

                          Comment

                          • Bruce - PhosphorMedia
                            Developer Partner











                            • Mar 2006
                            • 11257

                            #14
                            Re: Limiting Characters in Attribute Text Box

                            yea, i was going to ask...how can check boxes have a "length"....what you really are asking here is how can i control HOW MANY checkboxes are selected. (search on javascriptsource.com...probably have something there...i try to avoid javascript<g>)
                            Bruce Golub
                            Phosphor Media - "Your Success is our Business"

                            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                            phosphormedia.com

                            Comment

                            • GRM
                              Mini Mivite

                              • Jul 2010
                              • 14

                              #15
                              Re: Limiting Characters in Attribute Text Box

                              No, when a customer checks a checkbox, they are choosing size and type. They then has an option for engraving which is limited by what they checked. Some checkboxes would give the option for 14 characters of engraving and others would be 12 characters for engraving. So what I was looking for is when a customer would choose large, they would be able to put in 14 characters or if they chose small it would limit them to 12 characters.
                              GRM

                              Comment

                              Working...
                              X