All Projects → filamentgroup → Politespace

filamentgroup / Politespace

Licence: mit
Politely add spaces to numeric form values to increase readability (credit card numbers, phone numbers, etc).

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Politespace

i7n-pdfhtml
pdfHTML is an iText 7 add-on for C# (.NET) that allows you to easily convert HTML and CSS into standards compliant PDFs that are accessible, searchable and usable for indexing.
Stars: ✭ 111 (-79.14%)
Mutual labels:  accessibility, forms
accessible-forms
A series of HTML test cases to determine how specific elements are announced in different screen reader / browser combinations.
Stars: ✭ 159 (-70.11%)
Mutual labels:  accessibility, forms
I7j Pdfhtml
pdfHTML is an iText 7 add-on for Java that allows you to easily convert HTML and CSS into standards compliant PDFs that are accessible, searchable and usable for indexing.
Stars: ✭ 104 (-80.45%)
Mutual labels:  accessibility, forms
A11y styled form controls
Various styled accessible form controls
Stars: ✭ 335 (-37.03%)
Mutual labels:  accessibility, forms
Adapt framework
A toolkit for creating responsive, accessible, multilanguage HTML5 e-learning courses.
Stars: ✭ 473 (-11.09%)
Mutual labels:  accessibility
Colander
A serialization/deserialization/validation library for strings, mappings and lists.
Stars: ✭ 408 (-23.31%)
Mutual labels:  forms
Koa11y
Easily check for website accessibility issues
Stars: ✭ 403 (-24.25%)
Mutual labels:  accessibility
Optikey
OptiKey - Full computer control and speech with your eyes
Stars: ✭ 3,906 (+634.21%)
Mutual labels:  accessibility
Reakit
Toolkit for building accessible rich web apps with React
Stars: ✭ 5,265 (+889.66%)
Mutual labels:  accessibility
React Spectrum
A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
Stars: ✭ 5,876 (+1004.51%)
Mutual labels:  accessibility
Read Aloud
An awesome browser extension that reads aloud webpage content with one click
Stars: ✭ 444 (-16.54%)
Mutual labels:  accessibility
Forms Angular
Probably the most opinionated framework in the world
Stars: ✭ 412 (-22.56%)
Mutual labels:  forms
React Multistep
React multistep form component
Stars: ✭ 473 (-11.09%)
Mutual labels:  forms
Midnight Lizard
Сustom color schemes for all websites
Stars: ✭ 406 (-23.68%)
Mutual labels:  accessibility
Vue Autosuggest
🔍 Vue autosuggest component.
Stars: ✭ 492 (-7.52%)
Mutual labels:  accessibility
Equal Access
IBM Equal Access Accessibility Checker contains tools to automate accessibility checking from a browser or in a continuous development/build environment
Stars: ✭ 400 (-24.81%)
Mutual labels:  accessibility
Unform
Performance-focused API for React forms 🚀
Stars: ✭ 4,340 (+715.79%)
Mutual labels:  forms
Checkbox.css
☑️ Tiny set of pure CSS animations for your checkbox input. https://720kb.github.io/checkbox.css/
Stars: ✭ 478 (-10.15%)
Mutual labels:  forms
Construct.css
Focus on the content and structure of your HTML
Stars: ✭ 432 (-18.8%)
Mutual labels:  accessibility
Accesslint.js
Keep accessibility errors in check.
Stars: ✭ 423 (-20.49%)
Mutual labels:  accessibility

Politespace

npm version Build Status Dependency Status devDependency Status

Filament Group

Demo

Using Politespace

Add data-politespace to your form’s input[type=text] (et al) or textarea and we’ll add spaces to the value when the user blurs off of it. We’ll also remove those spaces on focus.

data-politespace-grouplength

To customize the number of spaces, use the data-politespace-grouplength attribute (it defaults to 3). It can be:

  • single number (to uniformly repeat, like a credit card)
  • a comma delimited list (for non-uniform strings, like "2,4" for MM YYYY). This also works with open ended commas, like "2," for MM YYYY or "3,3," for a US phone number.

Use pattern="[0-9]*" for numeric keyboards on iOS.

This script now works reliably cross-browser with <input type="number">. It should be noted that independent of politespace, WebKit removes the value on blur when a user types or a script adds a non-numeric character in the field, for example: myElement.value = "1,000". We’re now creating a proxy element on top of the form element to workaround this issue and display the formatted value.

Make sure your maxlength value is large enough to allow for the addition of the whitespace.

data-politespace-delimiter

The default delimiter is a space, but you can add data-politespace-delimiter to customize to a different character.

data-politespace-reverse

When delimiting money, for example, you want the grouplengths to be calculated from the lowest digit to the greatest (from right to left). Use data-politespace-reverse to opt into this behavior. A USD Price example: data-politespace-grouplength="3" data-politespace-delimiter="," data-politespace-reverse

data-politespace-decimal-mark

When delimiting money as a floating point, you’ll want to exclude the fractional portion of the number when inserting delimiters. For example, $4,000.34 will need data-politespace-delimiter="," data-politespace-decimal-mark="." (or for proper internationalization, $4 000,34 will need data-politespace-delimiter=" " data-politespace-decimal-mark=",").

data-politespace-strip

Specify a regular expression of characters to remove before formatting the field. To strip out all non-numeric characters (for example, for a telephone number), use data-politespace-strip="[^\d]*". This is an alternative to the numeric-input plugin of formcore.

data-politespace-creditcard

When using politespace with credit card fields, the formatting logic changes based on the first digit. For example, American Express (AMEX) card formats are 4,6,5 (15 characters total, the first digit is a 3) and Visa/Mastercard/Discover are 4,4,4,4 (16 characters). If you use the data-politespace-creditcard attribute (in lieu of a data-politespace-grouplength) politespace will automatically adjust the politespace group length for you. If you add the data-politespace-creditcard-maxlength attribute, politespace will also manage the field’s maxlength for you as well.

<input type="text" pattern="[0-9]*" data-politespace data-politespace-creditcard data-politespace-creditcard-maxlength>

Uses the creditable dependency.

data-politespace-us-telephone

When using politespace with US specific telephone number fields, data-politespace-us-telephone option will automatically adjust the maxlength of the field to account for a US country code. If the user types a 1, the maxlength will be adjusted to add one additional character until the user blurs, when the country code will be stripped and the original maxlength restored.

Download

NPM

npm install politespace

Beware input masks.

This plugin was created as a less intrusive alternative to the common input mask, which have serious accessibility implications:

A quick screen/audio recording of tabbing around a form using JS input masks with VoiceOver enabled.

@scottjehl

Just a friendly monthly reminder that input mask plugins make your forms sound like a jackhammer to people who use a screen reader. Cheers!

@scottjehl

Tests

Using the repo

Run these commands:

  • npm install
  • grunt as normal

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].