Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/h-gh/yii-jquery-form-validation
This plugin runs custom validations on custom fileds which are not in Yii model.
https://github.com/h-gh/yii-jquery-form-validation
jquery yii-model yii2 yii2-asset yii2-framework
Last synced: about 2 months ago
JSON representation
This plugin runs custom validations on custom fileds which are not in Yii model.
- Host: GitHub
- URL: https://github.com/h-gh/yii-jquery-form-validation
- Owner: H-Gh
- Created: 2017-10-07T11:26:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-06T14:37:06.000Z (over 5 years ago)
- Last Synced: 2024-10-18T00:26:13.072Z (2 months ago)
- Topics: jquery, yii-model, yii2, yii2-asset, yii2-framework
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Yii-jQuery-form-validation
This plugin runs custom validations on custom fileds which are not in Yii model.Usage
php
```php
book-name
echo Html::label("Label", "model-model_attribute_1"); ?>
echo Html::textInput("Model[model_attribute_1]", null, [
"class" => "form-control",
"id" => "model-model_attribute_1"
]);
?>
```jQuery
```javascript
var $form = $('#form');
$form.yiiValidator('add', {
model: "model",
attribute: "model_attribute_1",
rules: // ...
});
```methods
add
```javascript
var $form = $('#form');
$form.yiiValidator('add', {
//...
});
```Rules
Rules can be a single object or array of objects.```javascript
rules : {
//...
}
rules : [
{
//...
},
{
//...
}
];
```Each rule consists of two element :
```
rule
errorMessage
```Rule can be selected from below list or be a function.
```
required
number
url
``````javascript
rule : function(value) {
//...
}
```Example
```javascript
var $form = $('#form');
$form.yiiValidator('add', {
model: "model",
attribute: "model_attribute_1",
rules: [{
rule: "required",
errorMessage: "should fill"
}]
});
``````javascript
var $form = $('#form');
$form.yiiValidator('add', {
model: "model",
attribute: "model_attribute_2",
rules: [
{rule : "required", errorMessage : "should fill"},
{
rule: function (value) {
return value > 0 && value !== "";
},
errorMessage: "should more than zero!",
}
]
});
```