Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vdegenne/mwc-forms-util
A set of convenient methods for manipulating forms using @material elements.
https://github.com/vdegenne/mwc-forms-util
Last synced: about 1 month ago
JSON representation
A set of convenient methods for manipulating forms using @material elements.
- Host: GitHub
- URL: https://github.com/vdegenne/mwc-forms-util
- Owner: vdegenne
- Created: 2020-01-22T16:30:08.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T22:21:45.000Z (over 3 years ago)
- Last Synced: 2023-03-02T00:42:04.580Z (almost 2 years ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# @vdegenne/mwc-forms-util
A set of convenient methods for manipulating forms using @material elements.
> Work still in Progress
> Please don't hesitate to make some Pull Request to improve this module.## Installation
```bash
npm i @vdegenne/mwc-forms-util
```Then in your code
```javascript
import { ... } from '@vdegenne/mwc-forms-util';
```*(Note: You can use this same line for TypeScript project, the typings are already included in the package).*
You can also include this package directly in your html
```html
```
If you have a node module path resolver server then you can just type
```html
```
## Usage
### validateForm
```javascript
if (!validateForm(formElement)) {
console.log('something went wrong');
}
else {
// continue
}
```This function will also report the validity and the user-defined helper will be triggered (e.g. `mwc-textfield` will becomes red if it was required but the field is empty).
### serializeForm
Digests an object `{name: value}` representing the form.
```javascript
const object = serializeForm(formElement);
```### fillForm
```javascript
const object = {
name: 'Martin',
age: 32,
phone: '123-456
};fillForm(formElement, object);
```### resetForm(formElement)
Resets the form element.