Limiting text field to max character length

I am need to restrict certain text fields to not exceed certain character lengths (e.g 15 characters). Is there any way to have place a specific limit on certain fields so users cannot enter more than the limit?

  1. Give the field a unique className to make it easier to target.

  2. Get the Component_id of that component and update this code to reflect the component id and the class you assigned:

TB.render('component_8', function(data) {
    const inputField = document.querySelector(".myTestClass input");
    inputField.addEventListener("input", function() {
      if (this.value.length > 10) {
        this.value = this.value.substring(0, 10);