voltron schrieb:
Hi,

has anyone written a validator to check for alphanumeric values and a
min length for the validator plug in?
Take a look at this demo: http://dev.jquery.com/view/trunk/plugins/validate/demo-test/marketo/ It uses a custom method for the password, you can find it right at the top here: http://dev.jquery.com/view/trunk/plugins/validate/demo-test/marketo/mktSignup.js

        jQuery.validator.addMethod("password", function( value, element, param 
) {
                var result = this.optional(element) || value.length >= 6 && 
/\d/.test(value) && /\w/.test(value);
                if (!result) {
                        element.value = "";
                        var validator = this;
                        setTimeout(function() {
                                validator.blockFocusCleanup = true;
                                element.focus();
                                validator.blockFocusCleanup = false;
                        }, 1);
                }
                return result;
        }, "Your password must be at least 6 characters long and contain at least 
one number and one character.");

-- Jörn

Reply via email to