YouTip LogoYouTip

Jquery Plugin Prettydate

# jQuery Prettydate The jQuery Prettydate plugin provides powerful validation functionality for forms, making client-side form validation simpler while offering a wide range of customization options to meet various application needs. The plugin bundles a set of useful validation methods, including URL and email validation, and provides an API for writing user-defined methods. All bundled methods use English for error messages by default and have been translated into 37 other languages. The current version of the plugin is 1.1.0. Download the [jQuery Prettydate Validation (Password Validation) plugin](https://github.com/jzaefferer/jquery-prettydate). ## Usage To use the Prettydate plugin, you need elements with ISO8601 dates in their `title` attribute: January 28th, 2008 January 27th, 2008 January 26th, 2008 Then apply the `prettyDate` method to them: $(function() { $("a").prettyDate(); }); To localize the plugin, override the properties in `$.prettyDate.messages`. Here is an example for German localization: $.prettyDate.messages = { now: "gerade eben", minute: "vor einer Minute", minutes: $.prettyDate.template("vor {0} Minuten"), hour: "vor einer Stunde", hours: $.prettyDate.template("vor {0} Stunden"), yesterday: "Gestern", days: $.prettyDate.template("vor {0} Tagen"), weeks: $.prettyDate.template("vor {0} Wochen") } The plugin updates each selected element every 10 seconds. This way, "just now" becomes "1 minute ago", then "x minutes ago", then "1 hour ago", and so on. You can disable the interval updates by specifying the `interval` option as `false`: $(function() { $("a").prettyDate({ interval: false }); }); Or set a different interval, for example, `interval: 1000` to update each selected element every second: $(function() { $("a").prettyDate({ interval: 1000 }); }); The `value` option reads the ISO8601 date string from the `title` attribute by default. Override this option to use another attribute, for example, a custom "isodate" attribute: $(function() { $("a").prettyDate({function() { // "this" is the DOM elementreturn $(this).attr("isodate");} }); });
← Jquery Plugin TooltipJquery Plugin Password Validat β†’