3

I have a form that has an optional username/password input but when either the username or password has a value it causes them both to be required. Not sure how I should approach this? So far the validation looks a little wordy: enter image description here

I considered this kind of validation, but it gives an either/or impression:

enter image description here

1
  • 1
    1. Why user name and password fields are optional? 2. After adding the information how did you validate? Did you have a separate button for it? Please give more brief on this
    – Rishi Shah
    Mar 2 at 8:22
3

It appears that the username and password fields are related to creating a new user account, perhaps something that a system admin would do when setting up a new user (as opposed to a user doing it for their own account).

With this is mind, I would suggest making that part of the form a more explicit action. Only show those fields when they are required to be used.

For example, the form could initially look like this:

enter image description here

This way if the user only wants to specify the domain name, then they can fill that field in and submit the form.

If the user also wants to create a new user account, they can check the option to do that and then the additional fields can be shown.

enter image description here

At this point they will be required fields. This makes the validation message more simple, as those fields are never shown as optional. So you could just say:

The username and password fields are required when creating a new account.

1
  • Yes, good responsive disclosure, thank you! Mar 2 at 22:26
1

Username and password together are an entity that is optional. When the entity is wanted then the fields within it are required. What can we call this entity, "credentials"? Similar to musefans answer but with the emphasis on using a fieldset with legend and with the difference that you use buttons to explicitly add or remove the credentials. Name things you want of course.

Before:

enter image description here

After:

enter image description here

0

Username and password cannot be optional. I assume logging in into that specific flow is optional maybe or creating an account ? In this case you can include an explanatory text or group the username and password and state that login / signup is optional.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.