Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Liquid code does not work on a phone.

Liquid code does not work on a phone.

Emma_B2
Visitor
3 0 0

Hi

 

I have  liquid code which puts  a textarea on my site:.

 

<textarea id="Customisation" maxlength="10"
style="width:100%;height:50px;font-size:10pt;resize:none;scrollbar-width: none;" placeholder="Enter Text"> </textarea>

 

The maxlength attribute works in desktop and mobile mode under development however it doesn't restrict entry to 10 characters on my mobile phone -using using different browsers including Chrome

 

Any ideas?

Reply 1 (1)

Huptech-Web
Shopify Partner
1169 234 265

Hi @Emma_B2 , The "maxlength" in <textarea> is inconsistent across different devices. To fix the issue try adding the below script to your file code.

<script>
  const textarea = document.getElementById("Customisation");

  textarea.addEventListener("input", function() {
    const maxlength = this.getAttribute("maxlength");
    if (this.value.length > maxlength) {
      this.value = this.value.slice(0, maxlength);
    }
  });
</script>

 

 


AT...

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required