You are viewing limited content. For full access, please sign in.

Question

Question

Set Max Line Limit on Multi-line field

asked on February 13, 2018

I am working on a form that eventually populates a fillable PDF.  I have some comment boxes set as multi-line fields, but I need to ensure that whatever comments are written on the form will fit within the space allocated in the PDF.  I was going to just use maximum chars, but then realized that if a user puts carriage returns in the form it could cause those comments to exceed to space of the PDF and get cut off.  Is there a way to limit a multiline field by both max chars and max lines?

Thanks in advance!

0 0

Replies

replied on February 14, 2018

I saw someone do something similar. Here is a modified version. The example below will only accept 10 lines/returns

    var lines = 10;
    var linesUsed = 0;
    
    $('.yourclass textarea').keydown(function(e) {
        
        newLines = $(this).val().split("\n").length;
        
        if(e.keyCode == 13 && newLines >= lines) {

            return false;
        }
        else {

        }
    });

 

1 0
replied on February 26, 2018

Thanks Raul!  Do you know how to limit the number of characters per line?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.