vivin / regula

Regula: An annotation-based form-validation framework in Javascript
126 stars 24 forks source link

Fix for issue #13: Need a way to validate a subset of elements easily #19

Closed troyji closed 13 years ago

troyji commented 13 years ago

Fix

https://github.com/vivin/regula/issues/13

troyji commented 13 years ago

I just updated the pull request to include my latest addition.

I added an optional jquery plugin that wraps the validate method :-) It is built on top of the new regula functionality from issue #13.

Add the scripts:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="regula.js"></script>
<script type="text/javascript" src="jquery.regula.js"></script>

Regula jQuery usage:

$(selector).regula('validate', [options]);

Javascript usage example:

regula.bind();
var results = $("input").regula('validate');
$.each(results, function(i, r)
{
  alert(r.message);
});
troyji commented 13 years ago

I just updated the pull request to include new overloads for the bind function.

regula.bind([elements], [options]);

I also added support to the jquery plugin for bind.

$(selector).regula(); //bind selected elements

$(selector).regula('bind'); //bind selected elements

$(selector)regula(options); //bind selected elements with options

$(selector).regula('bind', options); //bind selected elements with options