Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change JQuery Validator Language Message

Tags:

Am using the JQuery Validator from http://bassistance.de/jquery-plugins/jquery-plugin-validation/. How can i make it so that the messages are custom and not in english.

like image 983
Luis Alvarado Avatar asked May 31 '11 00:05

Luis Alvarado


2 Answers

If you look into the directory "localization", you could find different .js files that cointains error messages in different languages. [something like "messages_XX.js"]

Choose the file of the language you need and just add the following line, into the tag , after the inclusion of the jquery.validate.js

<script type="text/javascript" src="localization/messages_XX.js"></script> 
like image 163
andre_lost Avatar answered Oct 28 '22 05:10

andre_lost


Do it like this:

$(document).ready(function() {   $("form#login").validate({     lang: 'en'  // or whatever language option you have.   }); }); 

If the language you wish to supply is not one of the default languages, then do this:

$.tools.validator.localize("fi", {     '*'          : 'Virheellinen arvo',     ':email'     : 'Virheellinen s&auml;hk&ouml;postiosoite',     ':number'    : 'Arvon on oltava numeerinen',     ':url'       : 'Virheellinen URL',     '[max]'      : 'Arvon on oltava pienempi, kuin $1',     '[min]'      : 'Arvon on oltava suurempi, kuin $1',     '[required]' : 'Kent&auml;n arvo on annettava' });    $("form#login").validate({     lang: 'fi'   }); 

See these instructions for more.

like image 21
Dave Sag Avatar answered Oct 28 '22 04:10

Dave Sag