Hello, i was trying to set some default messages for an instance of
jquery.validator. Saw that i can set only "global" default messages,
but not per instance... so i found a way of doing i but i need to add
a line on jquery.validate.js file:

@line 548 (jquery.validate.js):

                defaultMessage: function( element, method) {
                        return this.findDefined(
                                this.customMessage( element.name, method ),
                                this.customMetaMessage( element, method ),
                                this.settings.messages[method], // added this 
for default instance
messages
                                // title is never undefined, so handle empty 
string as undefined
                                !this.settings.ignoreTitle && element.title || 
undefined,
                                $.validator.messages[method],
                                "<strong>Warning: No message defined for " + 
element.name + "</
strong>"
                        );
                },

and i set the messages like this:
...
        var _messages = {
                required: "O campo {0} é de preenchimento obrigatório!",
                email: "O campo {0} deve conter um e-mail válido!"
        };
        for(var name in _messages){
                _this.validator.settings.messages[name] = _messages[name];
        }
...

It worked perfectly, but i really dont like to change the api js. If
anyone knows how to do it without changing the original js, please let
me know.

thanks

Reply via email to