jQuery - Add Validator Rule Dynamically?
<p>I'm trying to add a jQuery validator rule dynamically and it's not working. It doesn't throw any errors but doesn't trigger the validation.</p>

<p>Here's the js:</p>

<pre><code>$(document).ready(function () {

    $.validator.addMethod("TIME", function (value, element) {
        var re = new RegExp(regexp);
        console.debug("Validating " + value);
        return this.optional(element) || re.test("^*(1[0-2]|[1-9]):[0-5][0-9] *(a|p|A|P)(m|M)*$").test(value);
    }, "Time is invalid: Please enter a valid time.");

$("input[id *= '_timepicker']").rules("add", "TIME");

});
</code></pre>

<p>Any idea what's wrong?</p>

<p>EDIT:</p>

<p>Now I get an error: <strong>invalid quantifier *(1[0-2]|[1-9]):[0-5][0-9] <em>(a|p|A|P)(m|M)</em>$</strong></p>

<p>Here's the relevant js:</p>

<pre><code>rules:{"special.Hours.FridayHours1.close":{ regExp: /^*(1[0-2]|[1-9]):[0-5][0-9] *(a|p|A|P)(m|M)*$/ }
</code></pre>

<p>Here's the complete validate function:</p>

<p><a href="http://pastebin.com/YRday2Mv" rel="nofollow">http://pastebin.com/YRday2Mv</a></p>
