Q:

jQuery validate, different error message based on input type

I need change default error message of jQuery Validation Plugin. I have learned how to achieve this from here, and this working great. However i need some more customazation. Is it possible to set different error messages based on type of input field. 
I mean, for:
<input type="text" required>

default error massege should be "Filling this field is required". And for 
<input type="file" required>

default error massege should be "Attaching document is required".
I know that I can set error messages separately for fields like this:
$('form').validate({                
    messages: {
        FieldName: { required: "Attaching document is required" }
    }
});

Problem is that, the form is really huge, so I thought writing separate error messages would not be good solution.

A:

You would use the .rules('add') method combined with a jQuery .each() to globally change the error messages based on type.
$('input[type="text"]').each(function() {
    $(this).rules('add', {
        messages: {
            required: "this TEXT field is required"
        }
    })
});

$('input[type="file"]').each(function() {
    $(this).rules('add', {
        messages: {
            required: "this FILE upload field is required"
        }
    })
});

DEMO:  jsfiddle.net/cftesLwd/
My demo shows that you can use this method to change the message even in cases where you don't use this method to declare the rule itself.  Messages only show up on fields that contain the required attribute.  Otherwise, you can also easily declare the required rule for all inputs of these types even when you don't have the inline required attribute.

