├── .gitignore
├── LICENSE
├── README.md
├── bower.json
├── build.js
├── demo
├── bootstrap
│ ├── css
│ │ └── bootstrap.min.css
│ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ └── index.html
├── complex.html
├── semantic
│ ├── index.html
│ ├── semantic.min.css
│ └── themes
│ │ └── default
│ │ └── assets
│ │ └── fonts
│ │ ├── icons.eot
│ │ ├── icons.otf
│ │ ├── icons.ttf
│ │ ├── icons.woff
│ │ └── icons.woff2
├── simplest.html
└── style.css
├── dist
├── SMValidator.js
├── SMValidator.min.js
└── SMValidator.pure.min.js
├── package.json
└── src
├── SMValidator.js
└── config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 WLDragon
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SMValidator(strong muscle validator)
2 |
3 | ## Features
4 | - Light weight
5 |
6 | - No dependencies
7 |
8 | - Customizable rules messages and styles
9 |
10 | - Support bootstrap and semantic
11 |
12 | - Useable RegExp on html
13 |
14 | - Support IE8+
15 |
16 | ## Tutor And Documents
17 | - [中文版教程](https://wldragon.github.io/SMValidator/tutor/tutor1.html)
18 |
19 | - [English Tutor](https://wldragon.github.io/SMValidator/tutor/tutor-en1.html)
20 |
21 | - [快速开始](https://github.com/WLDragon/SMValidator/wiki/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
22 |
23 | ## Preview
24 | - **Required** (required rule in html)
25 |
26 | ``` html
27 |
28 | ```
29 |
30 | - **RegExp** (using RegExp in html)
31 |
32 | ``` html
33 |
34 | ```
35 |
36 | - **Your Style** (add .fail-error on input when validate failed)
37 |
38 | ``` html
39 |
40 | ```
41 |
42 | - **Javascript** (use only js without data-rule)
43 |
44 | ``` javascript
45 | new SMValidator('form', {
46 | rules: {
47 | //define a rule by RegExp
48 | onlyNumber: [/^-?\d+(\.{1}\d+)?$/, 'Please input letters'],
49 | //define a rule by Function
50 | greater: function(val, num) {
51 | return (val*1 > num*1) || 'Please input a number that greater than ' + num;
52 | }
53 | },
54 | fields: {
55 | //fieldName1 match input's name
56 | fieldName1: {
57 | required: true,
58 | rule: 'onlyNumber|greater(10)',
59 | failCss: 'fail-error'
60 | }
61 | }
62 | });
63 | ```
64 |
65 | ## Demos
66 | - [A complex demo](https://wldragon.github.io/SMValidator/)
67 |
68 | - Support third-party UI framework
69 |
79 |
80 | ## Install
81 | - ```npm install --save SMValidator```
82 |
83 | - ```bower install SMValidator```
84 |
85 | ## Build
86 | - ```npm run build```
87 |
88 | ## Notice
89 | - checkbox invalid in IE8
90 |
91 | - `