Making a custom clear text field button

When people add custom clear buttons to their text fields they generally do one of three things: They do not make them accessible at all. They unnecessarily add them to the keyboard focus order of the web page. They ensure the clear buttons are accessible – but not keyboard focusable. The clear button(s) do not show up when their associated fields are readonly or disabled, The button’s respect reading directionality of a web page (e.g., dir=rtl), and that keyboard focus returns to the text field once the clear button has been activated.


This content originally appeared on Scott O’Hara - Accessibility engineer, UX developer and designer and was authored by Scott O'Hara

When people add custom clear buttons to their text fields they generally do one of three things:

  1. They do not make them accessible at all.
  2. They unnecessarily add them to the keyboard focus order of the web page.
  3. They ensure the clear buttons are accessible - but not keyboard focusable. The clear button(s) do not show up when their associated fields are readonly or disabled, The button’s respect reading directionality of a web page (e.g., dir=rtl), and that keyboard focus returns to the text field once the clear button has been activated.

I cheated a bit with that third list item… there’s quite a few things in there, and even a few others that I didn’t directly call out.

Today I made a script to demonstrate how to add custom clear buttons to text fields.

Here is a demo page and explainer for more information on the markup pattern, script, and a more nuances that my piddly list did not cover.

Or you can check it out in the following iframe:

oh no! now there are two <main> and <h1> elements on my page because of the iframe content! Ah jeezy creezy… how will we all survive?


This content originally appeared on Scott O’Hara - Accessibility engineer, UX developer and designer and was authored by Scott O'Hara


Print Share Comment Cite Upload Translate Updates
APA

Scott O'Hara | Sciencx (2022-02-19T00:00:00+00:00) Making a custom clear text field button. Retrieved from https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/

MLA
" » Making a custom clear text field button." Scott O'Hara | Sciencx - Saturday February 19, 2022, https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/
HARVARD
Scott O'Hara | Sciencx Saturday February 19, 2022 » Making a custom clear text field button., viewed ,<https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/>
VANCOUVER
Scott O'Hara | Sciencx - » Making a custom clear text field button. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/
CHICAGO
" » Making a custom clear text field button." Scott O'Hara | Sciencx - Accessed . https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/
IEEE
" » Making a custom clear text field button." Scott O'Hara | Sciencx [Online]. Available: https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/. [Accessed: ]
rf:citation
» Making a custom clear text field button | Scott O'Hara | Sciencx | https://www.scien.cx/2022/02/19/making-a-custom-clear-text-field-button-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.