Skip to content

Commit

Permalink
polish docs
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek authored and f3l1x committed Dec 9, 2020
1 parent 9dc594c commit e402bbd
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 109 deletions.
93 changes: 93 additions & 0 deletions .docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Contributte / Live Form Validation

## Content

- [Install](#install)
- [NPM](#npm)
- [Manually](#manually)
- [CDN](#cdn)
- [Usage](#usage)
- [Options](#options)
- [Available options](#available-options)
- [Special features](#special-features)
- [Advanced](#advanced)

## Install

### NPM

```
npm install --save live-form-validation
```

### Manually

All you need is to link `live-form-validation.js` file from to your HTML document. That's it!

The script already contains the `netteForms.js` file, so don't use it again and remove it from your HTML document.

### CDN

- Dev: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@master/live-form-validation.js`
- Stable: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@v1.9.0/live-form-validation.js`

**Nette**

- Nette 3.0: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@master/live-form-validation.js`
- Nette 2.4: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@v1.9.0/live-form-validation.js`

## Usage

Script by default works nicely with Twitter Bootstrap 3, but you can customize the options to fit your exact needs.

### Options

You can change default options by calling `LiveForm.setOptions({ ... });` **after** including the script. Give only options that you want to change. For example:

```js
<script src="/js/live-form-validation.js"></script>
<script>
LiveForm.setOptions({
messageErrorPrefix: 'Error: ',
wait: 500
});
</script>
```

Alternatively, if you want to set options **before** the script is loaded, create `LiveFormOptions = { ... };` with options that you want to change. For example:

```js
<script>
LiveFormOptions = {
messageErrorPrefix: 'Error: ',
wait: 500
};
</script>
<script src="/js/live-form-validation.js"></script>
```

### Available options

Option | Description
------ | -----------
**showMessageClassOnParent** | CSS class of control's parent where error/valid class should be added; or "false" to use control directly
**messageParentClass** | CSS class of control's parent where error/valid message should be added (fallback to direct parent if not found); or "false" to use control's direct parent
**controlErrorClass** | CSS class for an invalid control
**controlValidClass** | CSS class for a valid control
**messageErrorClass** | CSS class for an error message
**enableHiddenMessageClass** | control with this CSS class will show error/valid message even when control itself is hidden (useful for controls which are hidden and wrapped into special component)
**disableLiveValidationClass** | control with this CSS class will have disabled live validation
**disableShowValidClass** | control with this CSS class will not show valid message
**messageTag** | tag that will hold the error/valid message
**messageIdPostfix** | message element id = control id + this postfix
**messageErrorPrefix** | show this html before error message itself
**showAllErrors** | show all errors when submitting form; or use "false" to show only first error
**showValid** | show message when valid
**wait** | delay in ms before validating on keyup/keydown; or use "false" to disable it
**focusScreenOffsetY** | vertical screen offset in px to scroll after focusing element with error (useful when using fixed navbar menu which may otherwise obscure the element in focus); or use "false" for default behavior

#### Special features
* **Form on load validation** - Adding class `validate-on-load` to form element will execute its validation immediately after page is loaded.

### Advanced
You can edit/replace methods `LiveForm.addError` (shows error message), `LiveForm.removeError` (hides error message), `LiveForm.showValid` (show message if input is correctly filled), `LiveForm.setupHandlers` (sets handlers up for inputs, like focus, blur, onkeyup). These methods can be altered to support some JS framework, ie. jQuery.
140 changes: 31 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,43 @@
# Live Form Validation
![](https://heatbadger.now.sh/github/readme/contributte/live-form-validation/)

:no_entry: Nice client-side live form validation for Nette Forms 3.0.
<p align=center>
<a href="https://travis-ci.org/contributte/live-form-validation"><img src="https://img.shields.io/travis/contributte/live-form-validation.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/live-form-validation"><img src="https://img.shields.io/npm/dt/live-form-validation.svg?style=flat-square"></a>
<a href="http://bit.ly/ctteg"><img src="https://img.shields.io/gitter/room/contributte/contributte.svg?style=flat-square"></a>
</p>
<p align=center>
<a href="https://github.com/contributte/live-form-validation/LICENSE"><img src="https://badgen.net/github/license/contributte/live-form-validation"></a>
<a href="https://bit.ly/ctteg"><img src="https://badgen.net/badge/support/gitter/cyan"></a>
<a href="https://bit.ly/cttfo"><img src="https://badgen.net/badge/support/forum/yellow"></a>
<a href="https://contributte.org/partners.html"><img src="https://badgen.net/badge/sponsor/donations/F96854"></a>
</p>

-----

[![Build Status](https://img.shields.io/travis/contributte/live-form-validation.svg?style=flat-square)](https://travis-ci.org/contributte/live-form-validation)
[![Licence](https://img.shields.io/github/license/contributte/live-form-validation.svg?style=flat-square)](https://github.com/contributte/live-form-validation)
[![Downloads total](https://img.shields.io/npm/dt/live-form-validation.svg?style=flat-square)](https://www.npmjs.com/package/live-form-validation)
[![Latest stable](https://img.shields.io/npm/v/live-form-validation.svg?style=flat-square)](https://www.npmjs.com/package/live-form-validation)
<p align=center>
Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact 👨🏻‍💻 <a href="https://f3l1x.io">f3l1x.io</a> | Twitter 🐦 <a href="https://twitter.com/contributte">@contributte</a>
</p>

## Discussion / Help
## Documentation

[![Join the chat](https://img.shields.io/gitter/room/contributte/contributte.svg?style=flat-square)](http://bit.ly/ctteg)
For details on how to use this package, check out our [documentation](.docs).

## Versions

| State | Version | Branch |
|-------------|---------------|----------|
| development | `dev-master` | `master` |
| stable | `^1.9.0` | `master` |

## Install

### NPM

```
npm install --save live-form-validation
```

### Manually

All you need is to link `live-form-validation.js` file from to your HTML document. That's it!

The script already contains the `netteForms.js` file, so don't use it again and remove it from your HTML document.

### CDN

- Dev: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@master/live-form-validation.js`
- Stable: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@v1.9.0/live-form-validation.js`

**Nette**

- Nette 3.0: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@master/live-form-validation.js`
- Nette 2.4: `https://cdn.jsdelivr.net/gh/contributte/live-form-validation@v1.9.0/live-form-validation.js`

## Usage

Script by default works nicely with Twitter Bootstrap 3, but you can customize the options to fit your exact needs.

### Options

You can change default options by calling `LiveForm.setOptions({ ... });` **after** including the script. Give only options that you want to change. For example:
| State | Version | Branch | Nette | PHP |
|-------------|---------------|----------|-------|---------|
| dev | `dev-master` | `master` | 3.0+ | `^7.4` |
| stable | `^0.1` | `master` | 3.0+ | `^7.3` |

```js
<script src="/js/live-form-validation.js"></script>
<script>
LiveForm.setOptions({
messageErrorPrefix: 'Error: ',
wait: 500
});
</script>
```
## Development

Alternatively, if you want to set options **before** the script is loaded, create `LiveFormOptions = { ... };` with options that you want to change. For example:
See [how to contribute](https://contributte.org/contributing.html) to this package.

```js
<script>
LiveFormOptions = {
messageErrorPrefix: 'Error: ',
wait: 500
};
</script>
<script src="/js/live-form-validation.js"></script>
```
This package is currently maintaining by these authors.

### Available options
<a href="https://github.com/f3l1x">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/538058?v=3&s=80">
</a>

Option | Description
------ | -----------
**showMessageClassOnParent** | CSS class of control's parent where error/valid class should be added; or "false" to use control directly
**messageParentClass** | CSS class of control's parent where error/valid message should be added (fallback to direct parent if not found); or "false" to use control's direct parent
**controlErrorClass** | CSS class for an invalid control
**controlValidClass** | CSS class for a valid control
**messageErrorClass** | CSS class for an error message
**enableHiddenMessageClass** | control with this CSS class will show error/valid message even when control itself is hidden (useful for controls which are hidden and wrapped into special component)
**disableLiveValidationClass** | control with this CSS class will have disabled live validation
**disableShowValidClass** | control with this CSS class will not show valid message
**messageTag** | tag that will hold the error/valid message
**messageIdPostfix** | message element id = control id + this postfix
**messageErrorPrefix** | show this html before error message itself
**showAllErrors** | show all errors when submitting form; or use "false" to show only first error
**showValid** | show message when valid
**wait** | delay in ms before validating on keyup/keydown; or use "false" to disable it
**focusScreenOffsetY** | vertical screen offset in px to scroll after focusing element with error (useful when using fixed navbar menu which may otherwise obscure the element in focus); or use "false" for default behavior

#### Special features
* **Form on load validation** - Adding class `validate-on-load` to form element will execute its validation immediately after page is loaded.

### Advanced
You can edit/replace methods `LiveForm.addError` (shows error message), `LiveForm.removeError` (hides error message), `LiveForm.showValid` (show message if input is correctly filled), `LiveForm.setupHandlers` (sets handlers up for inputs, like focus, blur, onkeyup). These methods can be altered to support some JS framework, ie. jQuery.

## Maintainers

<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/f3l1x">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/538058?v=3&s=150">
</a>
</br>
<a href="https://github.com/f3l1x">Milan Felix Šulc</a>
</td>
</tr>
</tbody>
</table>

## Authors
### Authors

This script is based on work of **Robert Pösel**, **zakrava**, **Radek Ježdík**, **MartyIX** and **David Grudl**.

Expand Down Expand Up @@ -164,6 +85,7 @@ This script is based on work of **Robert Pösel**, **zakrava**, **Radek Ježdík
</tbody>
</table>

---
-----

Thank you for testing, reporting and contributing.
Consider to [support](https://contributte.org/partners.html) **contributte** development team.
Also thank you for using this package.

0 comments on commit e402bbd

Please sign in to comment.