You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-46Lines changed: 21 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,6 @@ A form input builder and validator for React JS
6
6
|[How to use](#how-to-use)|[API](/API.md)|[Examples](/examples)|
7
7
|---|---|---|
8
8
9
-
### From version 0.12.0 Formsy only supports React 0.13.1 and up
10
-
11
9
## <aname="background">Background</a>
12
10
I wrote an article on forms and validation with React JS, [Nailing that validation with React JS](http://christianalfoni.github.io/javascript/2014/10/22/nailing-that-validation-with-reactjs.html), the result of that was this extension.
13
11
@@ -48,29 +46,29 @@ Complete API reference is available [here](/API.md).
48
46
49
47
#### Formsy gives you a form straight out of the box
<MyOwnInput name="email" validations="isEmail" validationError="This is not a valid email" required/>
@@ -84,31 +82,31 @@ Complete API reference is available [here](/API.md).
84
82
This code results in a form with a submit button that will run the `submit` method when the submit button is clicked with a valid email. The submit button is disabled as long as the input is empty ([required](/API.md#required)) or the value is not an email ([isEmail](/API.md#validators)). On validation error it will show the message: "This is not a valid email".
85
83
86
84
#### Building a form element (required)
87
-
```javascript
88
-
/** @jsx React.DOM */
89
-
var Formsy =require('formsy-react');
90
-
var MyOwnInput =React.createClass({
85
+
```jsx
86
+
importFormsyfrom'formsy-react';
87
+
88
+
constMyOwnInput=React.createClass({
91
89
92
90
// Add the Formsy Mixin
93
91
mixins: [Formsy.Mixin],
94
92
95
93
// setValue() will set the value of the component, which in
96
94
// turn will validate it and the rest of the form
97
-
changeValue:function(event) {
95
+
changeValue(event) {
98
96
this.setValue(event.currentTarget.value);
99
97
},
100
-
render:function () {
101
98
99
+
render() {
102
100
// Set a specific className based on the validation
103
101
// state of this component. showRequired() is true
104
102
// when the value is empty and the required prop is
105
103
// passed to the input. showError() is true when the
106
104
// value typed is invalid
107
-
var className =this.showRequired() ?'required':this.showError() ?'error':null;
0 commit comments