All Projects → corenzan → readonly.js

corenzan / readonly.js

Licence: MIT license
Make form controls - even <select> - read-only.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to readonly.js

veasy
A comprehensive react form solution which aims to eliminate all tedious logic.
Stars: ✭ 31 (-11.43%)
Mutual labels:  form
react-inputs-validation
A react component for form inputs validation. Online demo examples
Stars: ✭ 48 (+37.14%)
Mutual labels:  form
PHP-FileUpload
Simple and convenient file uploads — secure by default
Stars: ✭ 53 (+51.43%)
Mutual labels:  form
powermail
This is the official repository of the TYPO3 extension powermail! Powermail is a well-known, editor-friendly, powerful and easy mailform extension for TYPO3
Stars: ✭ 76 (+117.14%)
Mutual labels:  form
laravel-form-components
Form components built for Tailwind & Livewire.
Stars: ✭ 225 (+542.86%)
Mutual labels:  form
laravel-support-bubble
A non-intrusive support form that can be displayed on any page
Stars: ✭ 289 (+725.71%)
Mutual labels:  form
form-bunch
Form-bunch is a component like plugin that make it easier to write form, you could add the most of components what you want to form-bunch for build various form.
Stars: ✭ 18 (-48.57%)
Mutual labels:  form
final-form-arrays
Array Mutators for 🏁 Final Form
Stars: ✭ 64 (+82.86%)
Mutual labels:  form
file-input-accessor
Angular directive that provides file input functionality in Angular forms.
Stars: ✭ 32 (-8.57%)
Mutual labels:  form
ir-city-select
List of Iran provinces and cities to use in HTML forms. ( ~2.3KB gzipped )
Stars: ✭ 22 (-37.14%)
Mutual labels:  form
FrontendForms
A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
Stars: ✭ 0 (-100%)
Mutual labels:  form
react-form-firebase
Simple form with Firebase
Stars: ✭ 26 (-25.71%)
Mutual labels:  form
ATGValidator
iOS validation framework with form validation support
Stars: ✭ 51 (+45.71%)
Mutual labels:  form
react-use-hubspot-form
Embed HubSpot forms into your React components using hooks! Works with Create React App, Gatsby and other platforms.
Stars: ✭ 41 (+17.14%)
Mutual labels:  form
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (-20%)
Mutual labels:  form
mobx-react-form-devtools
DevTools for MobX React Form
Stars: ✭ 30 (-14.29%)
Mutual labels:  form
jasper-helpers
A library of helpers for working with html for apps Crystal
Stars: ✭ 20 (-42.86%)
Mutual labels:  form
dice-fairlink
JDBC Driver for read-only connections on AWS RDS Clusters
Stars: ✭ 33 (-5.71%)
Mutual labels:  readonly
react-input-handler
⚡️ Utility function to handle input changes in React.
Stars: ✭ 15 (-57.14%)
Mutual labels:  form
Formicula
A template-driven form mailer for Zikula
Stars: ✭ 19 (-45.71%)
Mutual labels:  form

Readonly.js

Make form controls - even <select> - read-only.

About

Readonly.js is a lightweight wrapper to fix the inconsistency of the readonly attribute in form controls. According to current specifications the attribute will be ignored in certain input types, and is completely void in <select> elements. This little helper aims to fix that. If you're curious to know more read the Web Standards section.

Upgrade to 3.x.x

If you're coming from older versions take note:

  • The control no longer gets a class added to it. You should use the attribute selector instead. e.g. select[readonly] { ... }
  • Now you can keep the actual control and its surrogate (formerly known as sham) in sync by dispatching a change event on the element. .e.g input.dispatchEvent(new Event('change')). This will make sure that changes to name and/or value made via JavaScript will take effect.

Compatibility

Version 3.0.0 was rewritten with a modern syntax but we're using Babel to transpile it into a more compatible JavaScript syntax wise. We also make use of some relatively newer browser APIs like querySelectorAll. Anything newer than IE11 should be fine but if you run into issues please submit an issue so we can look into it.

Usage

Only a single function is exported: readonly. e.g.

readonly('input, select');

This will toggle the read-only state of matching elements.

The first argument can be either:

  • A selector.
  • A single element.
  • A collection of elements (Array or NodeList).

You can also force a state by passing an additional argument; true for read-only or false for editable.

readonly('input, select', true);

If you're using jQuery it'll be installed as a plugin.

$('input, select').readonly(true);

Web Standards

Have you ever wondered why the readonly attribute doesn't work in <select> elements? Well, the whole thing is more complicated then one might think, but you can read all about it here: whatwg/html#2311. You also could help advance the web standards by leaving a comment with why such feature would be useful to you.

License

The MIT License © 2013 Arthur Corenzan. See LICENSE.md for full notice.

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].