[jQuery] [Validate] Example of custom rule w/ metadata only

[jQuery] [Validate] Example of custom rule w/ metadata only


I'm trying to work up a demo of a custom validation rule that uses
metadata only. I've cobbled the following together but the custom rule
never fires:
<script>
$(document).ready(function(){
jQuery.validator.addMethod("range_exp", function(value, element,
params) {
return this.optional(element) || ( (value >= params[0] && value <=
params[1]) || value == params[2] );
}, "Please enter between {0} and {1} or {2}");
$("#commentForm").validate();
});
</script>
<input id="WBC_I" type="text" size="6" validate="range_exp:[ 1,
999,'ND' ]" value="" name="WBC_I"/>
Obviously I've stripped a bit out, but what am I missing here?