|
|
@@ -294,21 +294,32 @@ $(form).bootstrapValidator({
|
|
|
});
|
|
|
```
|
|
|
|
|
|
+For Rails, the input field is constructed from model name and field name. For Example, User have email as field, when form helper render
|
|
|
+view, the input field name will be 'user[email]'. The syntax for these is somewhat different as shown below:
|
|
|
+
|
|
|
+```javascript
|
|
|
+$(form).bootstrapValidator({
|
|
|
+ fields: {
|
|
|
+ 'user[email]': {
|
|
|
+ // Replace <validatorName> with the name of validator
|
|
|
+ // <validatorOptions> will be passed as third parameter of the
|
|
|
+ // validate(validator, $field, options) method
|
|
|
+ <validatorName>: <validatorOptions>
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
+```
|
|
|
+
|
|
|
To see how built-in validators are developed, you can look at their sources located at the [```src/js/validator```](src/js/validator) directory.
|
|
|
|
|
|
## Build
|
|
|
|
|
|
BootstrapValidator uses [grunt](http://gruntjs.com) to simplify building process.
|
|
|
|
|
|
-From the BootstrapValidator root directory, execute the following commands to install the dependent packages (the administrator permission might be required):
|
|
|
+From the BootstrapValidator root directory, install dependencies:
|
|
|
|
|
|
```bash
|
|
|
-$ npm install grunt --save-dev
|
|
|
-$ npm install grunt-contrib-concat --save-dev
|
|
|
-$ npm install grunt-contrib-copy --save-dev
|
|
|
-$ npm install grunt-contrib-cssmin --save-dev
|
|
|
-$ npm install grunt-contrib-uglify --save-dev
|
|
|
-$ npm install grunt-contrib-watch --save-dev
|
|
|
+$ npm install
|
|
|
```
|
|
|
|
|
|
Then, uses grunt to build:
|
|
|
@@ -368,4 +379,4 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
-```
|
|
|
+```
|