Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ConfiForms Form Definition
formNamemyform

tatatextarea

addCounter(formName, formId);Run custom JavaScript

HTML
<script>


function addCounter(formName, formId) {
  var taElem = AJS.$('#' + formId).find('#i_ta');
  if (!taElem.hasClass('cfcounter')) {
   taElem.addClass('cfcounter');


   taElem.on("input", function(){
    var maxlength = 10;
    var currentLength = AJS.$(this).val().length;

    if( currentLength >= maxlength ){
        console.log("You have reached the maximum number of characters.");
    }else{
        console.log(maxlength - currentLength + " chars left");
    }
});


  }
}


</script>