Skip to content Skip to sidebar Skip to footer

Count Length Of One Input Field And Print It In Another With Gravity Forms And Javascript

I am using Gravity Forms for Wordpress and I am trying to figure out how to count the length of characters a user types into one of my input boxes and print that number to another

Solution 1:

Add an eventListener to the first input. In this case, whenever the user presses and releases a key, the length of the input will be displayed in the second input.

<form>
    <input name="input_10" id="input_1_10" type="text" value="" class="small" tabindex="1">
    <input name="input_2" id="input_1_2" type="text" value="" class="medium" tabindex="2">
</form>

<script>
    var bank = document.getElementById("input_1_10");
    var countNum = document.getElementById("input_1_2");
    bank.addEventListener("keyup", function(e) {
        countNum.value = bank.value.length;
    });
</script>

Post a Comment for "Count Length Of One Input Field And Print It In Another With Gravity Forms And Javascript"