JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
<form id="myform">
<input type="text" name="field[1]" />
<br/>
<input type="text" name="field[2]" />
<br/>
<input type="submit" />
</form>
<a id="docs" href="http://docs.jquery.com/Plugins/Validation" target="_blank">Validation Documentation</a>
CSS
#docs {
display: block;
position: fixed;
bottom: 0;
right: 0;
}
JavaScript
$(document).ready(function () {
$('#myform').validate({ // initialize the plugin
// other options
});
$("[name^=field]").each(function () {
$(this).rules("add", {
required: true,
checkValue: true
});
});
$.validator.addMethod("checkValue", function (value, element) {
var response = ((value > 0) && (value <= 100)) || ((value == 'test1') || (value == 'test2'));
return response;
}, "invalid value");
});