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

Question

Question

Required fields moving based on user input

asked on December 12, 2018

I have a form with required fields. I want the fields to not move when a user does not fill in any info in the field. It should only turn red to indicate the user needs to input something (and obviously give an error message when the user tries to submit). Here's how it looks now:

As you can see, the fields shift upwards when there is no user input. I already have hidden the parsley-required class, not sure what else to do.

0 0

Answer

SELECTED ANSWER
replied on December 12, 2018 Show version history

Figured it out. I had to set the property "display" to "none" instead of "visibility" to "hidden". Thank you for your help, Jason!

0 0

Replies

replied on December 12, 2018 Show version history

The problem you're encountering is actually the other fields shifting down due to the increased height of the field with the error message.

You can try adding the following to your form's CSS, but it is difficult to determine the exact selectors that are needed because it depends on your customization.

li.form-q {
    vertical-align:top;
}

It looks like you're using custom CSS to display things inline, in which case you may be able to add the vertical alignment styling to the same section where you put that styling.

 

Also, it looks like you're hiding the error message, but not the parent container based on the gap between the field and the "after" text.

Try adjusting the CSS selector to target the parent instead of the message contents (i.e. ".parsley-errors-list" instead of ".parsley-required')

1 0
replied on December 12, 2018

I applied this, and it seems to work. All other fields still move downwards, but everything is aligned properly now. Thank you!

0 0
replied on December 12, 2018

The reason the other fields move down is also due to the height change. To prevent that, you'll need to try what I suggest regarding hiding the error message's parent container instead of just the element containing the message.

0 0
replied on December 12, 2018 Show version history

I tried hiding the container, with no luck. Maybe I'm not hiding the correct class.

replied on December 12, 2018

I tried hiding the container class (.parsley-errors-list and .parsley-errors-list.filled) with no success. 

hidden class.png
hidden class.png (228.05 KB)
0 0
SELECTED ANSWER
replied on December 12, 2018 Show version history

Figured it out. I had to set the property "display" to "none" instead of "visibility" to "hidden". Thank you for your help, Jason!

0 0
replied on December 12, 2018 Show version history

Yes, Visibility affects whether or not an element can be seen, Display effects whether or not it is is rendered at all.

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

Sign in to reply to this post.