Workflow Soluiton

Expand all | Collapse all

Maximum Character Limit - Multi-Line Textbox?

Jump to Best Answer
  • 1.  Maximum Character Limit - Multi-Line Textbox?

    Posted 12-02-2014 06:23 PM

    Does workflow have a builtin component for specifying a character limit in a multiline text box?



  • 2.  RE: Maximum Character Limit - Multi-Line Textbox?

    Posted 12-02-2014 09:44 PM

    no, but you can use javascript to both limit the text and also to keep a length count (asc or desc) for the user if you want them to be aware of it.



  • 3.  RE: Maximum Character Limit - Multi-Line Textbox?

    Posted 12-03-2014 07:43 AM

    Agree with what africo says. Easiest way is to use an onblur event (when textbox loses focus) to make the current value a substring of the existing value (first character to the maxlength).

    To get fancier, and reinforce to the user that they've actually hit the maxlength, you'd probably use an onkey(press) event (key down probably) where you check the value, and if they've hit the maxlength, you escape out and not capture the key.



  • 4.  RE: Maximum Character Limit - Multi-Line Textbox?
    Best Answer

    Posted 12-03-2014 10:46 AM

    Thanks i figured i would have to go the JS route, for future searches here is what i've done.

    on the Form added the following snippet to the script section.

     

    Then used keyup and keydown events on the textbox to call the function.

    onkeydown= "limitText(this.form.textbox,this.form.countdown,1000);"

    onkeyup="limitText(this.form.textbox,this.form.countdown,1000);"

     

    Added another textbox ID'd as countdown to decrement the count (visually).

     

     

    function limitText(limitField, limitCount, limitNum)
    {
        if (limitField.value.length > limitNum) 
        {
            limitField.value = limitField.value.substring(0, limitNum); 
        }
        else
        {
            limitCount.value = limitNum - limitField.value.length;
        }
    } 


  • 5.  RE: Maximum Character Limit - Multi-Line Textbox?

    Posted 12-03-2014 10:51 AM

    keep in mind that onkeyup and onkeydown do not register copy/paste from the context menu.  if you find that you need to address that problem, try using oninput instead.  it's more work, but should be more comprehensive.

    Article: Workflow and Javascript oninput



  • 6.  RE: Maximum Character Limit - Multi-Line Textbox?

    Posted 12-03-2014 11:06 AM

    oh nice, thanks for that tip!