Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Form Validation Plugin Default Text

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) {
    $("#validationTest").validate({
        rules: {
            defaults: {
                messages: {required: "<img src='images/required.png' />"}
            }
        },
        submitHandler: function(form) {
            $(form).submit();
        }
    })
});

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

like image 951
Justin Avatar asked Sep 20 '26 19:09

Justin


1 Answers

You mean like this:

    $(document).ready(function(){
        $('#field').validate({
            rules: {
                f1: "required"
            },
            messages: {
                f1: "<img src='images/icons-coquette/accept.png' />"
            }
        })
    });

for all try $.extend

        $.extend(
            $.validator.messages, {
            required: "put your message here" //or put <img /> tag
        });
like image 107
msmafra Avatar answered Sep 23 '26 08:09

msmafra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!