Translate custom jQuery validation messages

0 votes

I have a question to ask regarding jQuery validation plugin.

I have used localisation to change the default language of error messages to be displayed in Spanish, but I cannot find anything regarding custom messages to be translated. Any clues?

for example

I've included the translation file for Spanish, and this is my code:

$('.signup-form').validate({
    lang : 'es',
    rules:{
        tandc : {required : true}
    },
    messages:{
        tandc : {required : "You have to accept terms and conditions to proceed further"}
    }
})

Default messages like "This field is required" etc are appearing in Spanish, now I want to translate the above message to Spanish but I cannot find where and how to define the translated text.

Aug 1, 2022 in Web Development by gaurav
• 23,260 points
2,634 views

1 answer to this question.

0 votes

we use a snippet like the following to translate error messages into DE:

    $.extend($.validator.messages, {
        required: "Dieses Feld ist ein Pflichtfeld.",
        maxlength: $.validator.format("Geben Sie bitte maximal {0} Zeichen ein."),
        minlength: $.validator.format("Geben Sie bitte mindestens {0} Zeichen ein."),
        rangelength: $.validator.format("Geben Sie bitte mindestens {0} und maximal {1} Zeichen ein."),
        email: "Geben Sie bitte eine gültige E-Mail-Adresse ein.",
        url: "Geben Sie bitte eine gültige URL ein.",
        date: "Bitte geben Sie ein gültiges Datum ein.",
        number: "Geben Sie bitte eine Nummer ein.",
        digits: "Geben Sie bitte nur Ziffern ein.",
        equalTo: "Bitte denselben Wert wiederholen.",
        range: $.validator.format("Geben Sie bitte einen Wert zwischen {0} und {1} ein."),
        max: $.validator.format("Geben Sie bitte einen Wert kleiner oder gleich {0} ein."),
        min: $.validator.format("Geben Sie bitte einen Wert größer oder gleich {0} ein."),
        creditcard: "Geben Sie bitte eine gültige Kreditkarten-Nummer ein."
    });

maybe this is usefull for you.

answered Aug 1, 2022 by rajatha
• 7,680 points

Related Questions In Web Development

0 votes
0 answers

how to spin and stop wheel has custom position with jquery

this i my code. I am using this ...READ MORE

Jul 27, 2022 in Web Development by gaurav
• 23,260 points
1,641 views
0 votes
0 answers

jQuery validation of NANP Phone numbers

I'm trying to validate my form. In ...READ MORE

Aug 19, 2022 in Web Development by gaurav
• 23,260 points
1,267 views
0 votes
0 answers

JQuery Validation - Remote method always check and become true before submit the form

Using jQuery validation plugin, I have been ...READ MORE

Aug 24, 2022 in Web Development by gaurav
• 23,260 points
2,905 views
0 votes
0 answers

mean menu custom width call in jquery

js every thing works fine but i ...READ MORE

Aug 24, 2022 in Web Development by gaurav
• 23,260 points
552 views
0 votes
0 answers

Jquery validation plugin - TypeError: $(...).validate is not a function

I am getting an error in my ...READ MORE

May 7, 2022 in Java-Script by narikkadan
• 63,600 points
1,443 views
0 votes
1 answer

Jquery validation plugin - TypeError: $(...).validate is not a function

The "$(...). validate is not a function" ...READ MORE

answered Jun 28, 2022 in JQuery by rajatha
• 7,680 points
16,532 views
0 votes
1 answer

jQuery Validation plugin. Two custom rules not working

validation plugin works according to the name attribute and ...READ MORE

answered Jun 20, 2022 in JQuery by rajatha
• 7,680 points
1,475 views
0 votes
1 answer

how to add erroricon and custom validation message using jquery?

By default, the error message is put ...READ MORE

answered Jun 30, 2022 in Web Development by rajatha
• 7,680 points
4,586 views
0 votes
1 answer

Translating a page with jquery "translator", google translate etc

Why not use Google's Website Translator? They have ...READ MORE

answered Aug 1, 2022 in Web Development by rajatha
• 7,680 points
1,376 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP