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

Question

Question

Dynamic Width of field

asked on April 25, 2017

Hi,

I have a field in Table & it fills Email of the user.

Since the email text can get bigger depending upon the text, I was wondering if someone could help me with javascript where the field dynamically adjusts width as per the text?

 

Regards,

S

0 0

Replies

replied on April 25, 2017

That would be an odd behavior since most users already know that the content of the box is inside the box. I would simply make the box big enough to fit most email addresses.

If you still want to flirt with the idea, I saw this code around and tried it in LF Forms. Works fine, but there might be others more elegant.

Just replace the "youremailbox" with the class name of your email box.

  $('.youremailbox input').keypress(function() {
    var txtWidth = $(this).width();
    var cs = $(this).val().length;

    if(cs>17){
       $(this).width(txtWidth+5);
    }
});

 

0 0
replied on April 26, 2017

Thanks Raul,

However the above code doesn't autosize the field....

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

Sign in to reply to this post.