Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form validation patterns for Conditionally revealing content #249

Closed
trevorsaint opened this issue Jun 8, 2016 · 18 comments · Fixed by #286
Closed

Form validation patterns for Conditionally revealing content #249

trevorsaint opened this issue Jun 8, 2016 · 18 comments · Fixed by #286

Comments

@trevorsaint
Copy link

trevorsaint commented Jun 8, 2016

I'm looking at form validation patterns.

It would be good for a collection of validation patterns which incorporate conditionally revealing content.

As an example:
ni-number-error

The first validation in this case would be: Choose an answer

Secondly if yes has been chosen we now have the error on the National Insurance number and not the answer.

ni-number-input-error

It would be interesting to see how you handle the styling aspects of this and if it has been considered.

Thanks

@edwardhorsford
Copy link
Contributor

Here's how we did it on passports. I think your repurposing of the grey
inset border is nicer.

[image: Inline images 1]
[image: Inline images 3]

On 8 June 2016 at 10:06, Trevor Saint [email protected] wrote:

I'm looking at email validation patterns.

It would be good for a collection of validation patterns which incorporate
conditionally revealing content.

As an example:
[image: ni-number-error]
https://cloud.githubusercontent.com/assets/4989027/15888692/cb797328-2d5f-11e6-9e10-03edb0187f89.png

The first validation in this case would be: Choose an answer

Secondly if yes has been chosen we now have the error on the National
Insurance number and not the answer.

[image: ni-number-input-error]
https://cloud.githubusercontent.com/assets/4989027/15888798/5287ed68-2d60-11e6-897d-52cc01f60746.png

It would be interesting to see how you handle the styling aspects of this
and if it has been considered.

Thanks


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#249, or mute the
thread
https://github.com/notifications/unsubscribe/ACGiQLtLK_3O4G4zuteAkh4sPypfDHyaks5qJoYYgaJpZM4Iwvrf
.


Ed Horsford

Designer
Government Digital Service

@trevorsaint
Copy link
Author

Hi Ed.

I do agree in that it looks nicer but the pattern we have does not allow this. I would effectively be adding the error onto the panel itself instead of form-group.

I can't see your images if you attached any?

Trevor

@edwardhorsford
Copy link
Contributor

Sorry, I replied via email. Didn't realise this was a github message.

Images from passports:
screen shot 2016-06-08 at 10 53 23
screen shot 2016-06-08 at 10 53 32

@trevorsaint
Copy link
Author

No problem Ed

I can see now what you are talking about.

Wow those labels are massive :).

I personally think the twin lines do not look as nice. And the way I showed it above does look better (my opinion only).

I will role with whatever GDS suggest, but do feel that a pattern for this has not been thought out or is in the todo list.

Cheers,

Trevor

@gemmaleigh
Copy link
Contributor

gemmaleigh commented Jun 9, 2016

I see what you mean. The first example works but only if there is only one field in the revealed section, if there is more than one then the red line is ambiguous (as to which field has the error).

cc. @timpaul who is prioritising work for the Patterns and tools team.

@trevorsaint
Copy link
Author

Thanks Gemma. That would be most helpful :)

@robinwhittleton
Copy link
Contributor

On Verify (e.g. on the ‘Do you have a mobile phone or tablet?’ page) we just turn the color of the conditional panel’s border from grey to red. In that case though we only have one question in the panel so we can get away from it.
verify_errors

@edwardhorsford
Copy link
Contributor

I'm somewhat wary of just changing the colour, though it does look nice - If you struggle to distinguish colours, not much changes when an error happens. Is it clear enough what to do?

@trevorsaint
Copy link
Author

I have modified the html. Added the error class not specifically on the form-group and it can work.

I feel that this does look a lot better. Obviosuly i have only added the error class and not the messages but you should be able to get the idea from this visual.

suggestion

@timpaul
Copy link
Contributor

timpaul commented Jun 10, 2016

This is good, but I think we can simplify further and remove the red border from the parent question:

image

After all, there's nothing actually wrong with the users response on that part of the form.

The double-borders effect I can live with as it's an error, and at least the borders are aligned and of equal thickness.

@edwardhorsford
Copy link
Contributor

👍 This is pretty much how we handled it on passports.

@trevorsaint
Copy link
Author

trevorsaint commented Jun 10, 2016

@timpaul

I hear your suggestion. The problem I am faced with is this. A selection must be made initially. If a user clicks Save and continue without making a selection, we need an error notification for the user.

screenshot-localhost 3000 2016-06-10 10-57-17

Lets say the user then makes a selection. We would still have the red border on the parent selection because we have not clicked Save and continue again.

Do you see the problem?

@edwardhorsford
Copy link
Contributor

In that case, the child element wouldn't have the error, since that hasn't been submitted yet?

If they then click submit without answering the child question, I'd expect the error on the child only.

@trevorsaint
Copy link
Author

trevorsaint commented Jun 10, 2016

You are exactly right :)

joelanman pushed a commit to joelanman/govuk_elements that referenced this issue Jun 13, 2016
# 4.9.0

- Add websafe organisation colours
- Split colours into two files with backwards-compatible colours.scss
replacement

# 4.8.2

- Add GOV.UK lint to lint scss files (PR alphagov#260)
- Remove reference to old colour palette (PR alphagov#256)
- Fix link to GOV.UK elements - tabular data

# 4.8.1

- Update DEFRA brand colour to new green (PR alphagov#249)

# 4.8.0

- Pass cohort name to analytics when using multivariate test (PR alphagov#251)

# 4.7.0

- Add 'mailto' tracking to GOV.UK Analytics (PR alphagov#244)
@trevorsaint
Copy link
Author

trevorsaint commented Jun 13, 2016

Hi @edwardhorsford

Your solution works in most scenarios by modifying html. In this situation the input inherits the style error from the parent.

inherit

inherit-2

I am wondering if the .error .form-control is an ideal css attribute?

<fieldset class="error">

  <legend>
    <span class="form-label-bold">How often do you get paid?</span>
    <span class="error-message">Choose an answer</span>
  </legend>

   <label>
      <input type="radio">
   </label>

   <div class="panel">
      <input type="text">
   </div>

   <label>
      <input type="radio">
   </label>

   <div class="panel">
      <input type="text">
   </div>

</fieldset>

A similar example on GOV Elements is: How do you want to be contacted?
http://govuk-elements.herokuapp.com/form-elements/example-form-elements/

Do you have an ideas or suggestions?

Thanks

@gavboulton
Copy link
Contributor

I'm in the process of updating the styles on the passports project to use more of elements. Can we increase the specificity of the form-control error styles using something like .error > .form-control?

We have .form-groups within .form-groups for progressive reveals and for dates. If the parent group or fieldset has an error the form-control of the child group inherits the error border.

@gemmaleigh
Copy link
Contributor

gemmaleigh commented Aug 18, 2016

Hi @trevorsaint and @gavboulton.

@gavboulton thanks, that works brilliantly.

@trevorsaint let me know if these examples work for you.

I've added a couple of examples to the form examples page - you can see them here:

http://govuk-elements-test.herokuapp.com/form-elements/example-form-elements/#example-conditional-errors

Here's the screenshots, let me know if this fixes the issues with nested errors.

example form elements form elements gov uk elements

@gemmaleigh
Copy link
Contributor

Hi @trevorsaint can you please let me know if #286 fixes this issue for you. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants