jQuery Form Validation plugin with multiple rules

Viewed 14485

I'm using the jQueryValidation plugin. Problem: I would like to use multiple pattern rules within for one input field. E.g.:

$("form").validate({
 rules: {
    "email": {
        required: true,
        email: true
    },
    "password": {
        required: true,
        pattern: /^[A-Za-z0-9\w]{4,20}/,
        pattern: /^[\d\w\xC4\xD6\xDC\xE4\xF6\xFC\xDF]*$/
    }
 }
});

What happens: the plugin tests only the second pattern rule. E.g. entering something like "tst" works (as this fulfils the seconds pattern) although it violates the first pattern rule.

As far as I understand the logic of rules in this plugin, all rules have to return TRUE in order to validate a form.

1 Answers
Related