Georgiawhoknows
-
Posts
4 -
Joined
-
Last visited
Content Type
Forums
Gallery
Blogs
Events
Store
Downloads
Profiles
Posts posted by Georgiawhoknows
-
-
On 7/29/2021 at 1:54 AM, creedon said:
Yes indeedy!
Please see my November 21, 2020 post earlier in this thread. The code linked to there should do the trick.
You'll want to set the following for your need.
  const formName = 'Gift message';      const maxLength = 80;      const formFieldLabel = 'Gift message';   Â
Let us know how it goes.
Dear Thomas!
I have tried using your code but it doesn't seem to be working. Do you know what could be an issue?
Thank you for your help.
Kind regards,
Georgia
<script>
 $( ( ) => {
  /*
  Â
   set store product detail named form labeled text field character max
   length
   Â
   Version     : 0.2d0
   Â
   SS Versions   : 7.0, 7.1
   Â
   v7.0 Templates  : Brine ( Aria, Blend, Burke, Cacao, Clay, Fairfield,
            Feed, Foster, Greenwich, Hatch, Heights, Hunter, Hyde,
            Impact, Jaunt, Juke, Keene, Kin, Lincoln, Maple, Margot,
            Marta, Mentor, Mercer, Miller, Mojave, Moksha, Motto,
            Nueva, Pedro, Pursuit, Rally, Rover, Royce, Sofia,
            Sonora, Stella, Thorne, Vow, Wav, West )
            Â
            your template is not listed? then it is not currently
            supported
   Â
   Dependancies   : jQuery
            Â
            twcsl
   Â
   Notes      : this code is for forms added as part of the product
            editor :
            Â
             Classic Editor > Form or
             Â
             New Editor > Customize > Custom Forms
             Â
            it is not for forms added through :
            Â
             Classic Editor > Additional Info or
             Â
             New Editor > Customize > Additional Info
             Â
            a text form field is either a text or text area field
   Â
   By        : Thomas Creedon < http://www.tomsWeb.consulting/ >
   Â
   */  /* for formName copy the value from the form editor Form Name field. you
    only need exactly what can be selected from the field */  const formName = 'Gift message';
  const maxLength = 80;
  /* for formFieldLabel copy the value from the form Text Area field editor
    LABEL field. you only need exactly what can be selected from the field */  const formFieldLabel = 'Gift message';
  // do not change anything below, there be the borg here
  if ( ! twcsl.storePage.isDetail ) return; // bail if not detail
  // bail if no mutation observer available
  if ( ! ( 'MutationObserver' in window ) ) return;
  // begin get form field text labeled
   var getFormFieldTextLabeled = ( label, $form ) => {
    let $it = undefined;
    $( '.text, .textarea', $form ).each ( function ( ) {
     const $this = $( this );
     const title = twcsl.getFormFieldLabel ( $this );
     if ( title != label ) return true; // continue if not our field
     $it = $( 'input, textarea', $this );
     return false;
     } );
    return $it;
    }
   // end get form field text labeled
  const observer = new MutationObserver ( function ( mutations ) {
   $.each ( mutations, function ( ) {
    if ( ! this.addedNodes.length ) return;
    let $element = $( this.addedNodes [ 0 ] );
    if ( ! $element.hasClass ( 'sqs-modal-lightbox' ) ) return;
    if ( $( '.form-title', $element ).text ( ) != formName ) return;
    const $form = $( 'form', $element );
    const $text = getFormFieldTextLabeled ( formFieldLabel, $form );
    if ( $text === undefined ) return true; // continue if no element
    $text.attr ( 'maxLength', maxLength );
    } );
   } );
  // start listening for changes in body
  observer.observe ( document.body, { childList : true } );
  } );
 </script>
-
Dear Thomas! Would it be possible for you to create a code for 80 characters gift message?
Â
You can find a form here https://www.glassitude.com/shop/p/sea-turtle-glass-straw and you just need to add a product to the basket in order for the form to pop up.Â
Thank you so much for your help and time.Kind regards,
Georgia -
Dear @Creedon,
Can I kindly ask you for your help?
I have created a gift form where I allow people to leave a gift message but it has to be maximum 80 characters can you please help me with the code?
Website www.glassitude.comGift form is set up at the check out.
Website password Seaside.
Â
Thank you for your help and time.
Kind regards,
Georgia
Limit Character Count on Forms
in Customize with code
Posted
Thank you so much it worked! 🙂 I really appreciate your help Thomas! 🙂
Best of luck with everything! You are amazing!