Home > Forum > Forms > Hide form fields on load

Hide form fields on load
0

Hey there.

What's your preferred way of hiding form fields on page load?
In my scenario form fields should remain hidden, unless a form field rule from another field was triggered on value change that 'unhides' the target form field.

I've been doing it the following way:

1. Make the field that should not be shown upon form load visible in the Field Matrix
2. Insert the 'Hide' JavaScript function into the main form behavior of the step
2. Create a form rule which shows/hides based on a condition
3. Add the form rule to the field that is supposed to trigger show/hide for the target field under 'Form rule to be executed on value change'

This works well but is a little cumbersome if done for multiple fields. Moreover, I feel that it might have a performance impact as well.

So what do you think?

MVP

Hi Flo,

I'm using a similar approach.

1. Using the form field matrix to define which fields should be visible in general.
2. Create a form rule.
3. Use this from rule in the "on value change"
4. Add this "Main form" Behavior" tab and add "if (step =1) then ExecuteFormRule".

I don't like to navigate into each step and I don't expect that it would cause a noticeable difference on the client.

But you can check this yourself, there's no need to rely on feelings. :)
Activate the diagnostic mode and check which elements take considerable time. See the screenshot for an example.

Best regards,
Daniel

MVP
In reply to: Flo

Hi Daniel,

thanks for your description.
May I ask to expand upon 3. and 4.?

The form rule created in 2. is for the form field and with 3. you mean to simply insert it into the 'on value change' of said field right?
And don't I need another form rule that simply hides the form field on page load and put this into the 'Main form behavior' targeting a certain step if need be?

Thanks for clarifying.

Hi Flo,

I should have added a screenshot in the first post. :)

The screenshot shows the Behavior "Form rule to be executed on page load".
Multiply form rules are executed depending on the current step.
The used form rules always checks the condition (field value) and either hides or shows the related fields.
This way I can reuse the same rule in all both situations. There's maybe a delay, but I prefer to have only a single place which I need to change. :)


In case you don't know it, you can right click on the function (show/hide) and a context menu will open, which displays alternatives. You can switch form show to hide very easy this way.

Best regards,
Daniel