Comments (3)
I think this may be beyond the scope of this plugin. I understand the use case and appreciate the suggestion, but I think I'm going to pass for now.
If you implement it sometime and are happy enough with the result to submit a pull request, I'll gladly reconsider. :)
from jquery-validator.
I see your point. However, only a minor modification will help me to achieve my goal. The "data-validations" validation attribute is hard-coded in the source code (line 44). All I need is that the validations attribute name can be specified in the method just like events, selector, preventDefault, etc. Something like this (showing diff output):
9a10
validation_attr : "validations",
38c39
< validate : function (selector, callback) {
validate : function (selector, validation_attr, callback) {
44c45
< var validation_rules = $(this).data("validations"),
var validation_rules = $(this).data(validation_attr),
322a324,327
if (!options.validation_attr) {
options.validation_attr = defaults.validation_attr;
}327c332
< var valid = validations.validate(options.selector || this, options.callback);
var valid = validations.validate(options.selector || this, options.validation_attr, options.callback);
Then my code would be as follows:
$.fn.errors = function (method) {
method.validation_attr = 'errors';
return $.fn.validator.call(this, method);
};
$.fn.warnings = function (method) {
method.validation_attr = 'warnings';
return $.fn.validator.call(this, method);
};
$('myform').errors({
events : 'submit',
selector : 'input[type!=submit], select, textarea',
preventDefaultIfInvalid : true,
callback : function(elem, valid) {
if (!valid) {
$(elem).addClass('error');
} else {
$(elem).removeClass('error');
}
}
});
$('myform').warnings({
events : 'blur change',
selector : 'input[type!=submit], select, textarea',
callback : function(elem, valid) {
if (!valid) {
$(elem).addClass('warning');
} else {
$(elem).removeClass('warning');
}
}
});
from jquery-validator.
Sold. I'll try to add this as I work on tests.
from jquery-validator.
Related Issues (20)
- Validation fails for radio buttons. HOT 4
- Validation fails after second submit when new validation rules are added. HOT 2
- Would it be possible to add custom validations? HOT 6
- The size validation rule does not work for non numeric attributes. HOT 3
- Negative numbers are always validated as invalid.
- Length validation fails to flag max length has been exceeded when textarea contains linefeeds.
- Validation crashes when using [] brackets in name of input element.
- Validation crashes for mutiple select. HOT 4
- Validation fails when input element has no 'name' attribute.
- The jquery-validator.js plugin fails JSLint (The JavaScript Code Quality Tool from Douglas Crockford). HOT 1
- Laravel 4 package HOT 2
- ReadMe.md missing "!" HOT 1
- A way to know which validation failed? HOT 2
- Can't install in laravel 4 HOT 1
- laravel 4 HOT 1
- Can you update this to Laravel 4? HOT 3
- validate_accepted() ignores checked status on checkboxes HOT 1
- it didn't have packagist json code HOT 1
- where is the error message displayed HOT 2
- The size attribute with file input type doesn't seem to be working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-validator.