Take the 2-minute tour ×

Hi I am using jQuery Form Validation Plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/

And I know that the default text is using "This field is required." And I am wanting to replace it with an IMG tag. But I don't want to change it within the actual PLUGIN, and wondering if it can be done just generically through the plugin options. I have tried many variations but have come up with this cut-down version.

$(document).ready(function(e) {
        rules: {
            defaults: {
                messages: {required: "<img src='images/required.png' />"}
        submitHandler: function(form) {

But this still doesn't work... any thoughts or direction would be appreciated.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You mean like this:

            rules: {
                f1: "required"
            messages: {
                f1: "<img src='images/icons-coquette/accept.png' />"

for all try $.extend

            $.validator.messages, {
            required: "put your message here" //or put <img /> tag
share|improve this answer
Hey, I just want to set it in 1 place for all the fields... not specific to a field. –  Justin May 28 '11 at 22:35
Oh! Sorry. You probably could remove the message inside the jquery.validate.js and put the image tag there, for a dirty sollution. :) I'll search for an better answer –  tenshimsm May 28 '11 at 22:40
This is correct: just to clarify, you can put an img tag inside of the "put your message here" text. –  Andrew Whitaker May 28 '11 at 23:01
I know but you want to be default for all, isn't? See above for the jQuery $.extend utility –  tenshimsm May 28 '11 at 23:06
Cheers thank you! –  Justin May 28 '11 at 23:18
add comment

Your Answer


