Multiline textbox on web form

Good morning,

I have searched other threads and tried to add the JS for creating a bigger text box to encourage submitters to provide a detailed reply, but none seem to be working.

Currently I have the following:

fd.Rendered(function() {
//Replace FieldName with the internal name of the field
var textArea = fd.field('myfieldname').$refs.textarea;
function recalcHeight() {
textArea.style.height = (textArea.scrollHeight > textArea.clientHeight) ? (textArea.scrollHeight) + "px" : "120px";
}
recalcHeight();
$(textArea).keyup(recalcHeight);
});

Please can someone point me in the right direction?

Kind regards,
Rob

Hi @robn,

Could you share more about your use case? Do you need the field to simply make the field taller, or do you need to adjust it depending on variables like input text or screen size?

If you don't need to update the height dynamically, the simplest solution would be to set it with CSS:

.fd-form textarea.form-control {
    height: 500px;
}

Hi @IliaLazarevskii ,

I would like the field to be taller. Do I add the CSS to the class area?

Kind regards
Rob

Hi @robn,

Yes, just paste it into the custom CSS of your form:

It will make all Note fields on your form tall. If you need to adjust one specific field, change the style to:

.yourclass {
    height: 500px;
}

And apply it like so:
Screenshot (206)

Hi @IliaLazarevskii,

I tried testing that way, but it resulted in the space between questions rather than text box height. I don't want to apply to every text area of the form.

Kind regards,
Rob
CSS
class

What kind of fields are you using?

If these are simple Text fields, I'd suggest replacing them with Note fields. They work pretty much the same, but allow many lines of text. The CSS I provided only works with Note fields. Also, it should be adjusted like so:

.yourclass textarea.form-control {
    height: 500px;
}

Any Note field with class 'yourclass' will be 500 pixels tall.

Hi @IliaLazarevskii,

I think I figured it out, but this doesn't achieve what I needed. It is making the text area larger but text starts mid-way down and input goes on one continuous line as before. I think a box that changes dynamically in size as the user puts in input is what I am looking for.

Kind regards,
Rob
CSS_1

I will try this, thank you!

It sounds like you might not need CSS at all, just check out the Note field.
Let me know how it goes!

1 Like

This is just what I was looking for. Thank you @IliaLazarevskii!