jQuery Prettydate
jQueryPrettydate
jQuery Prettydate plug-in provides powerful validation functions for forms, making client-side form validation easier while providing Plenty 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 this plug-in is 1.1.0.
Download the jQuery Prettydate Validation (password verification) plug-in.
How to use
To use the Prettydate plug-in, you need to have ISO8601 dates in the title:
January 28th, 2008 January 27th, 2008 January 26th, 2008
Then apply the prettyDate method to them:
$(function() { $("a").prettyDate(); });
To localize the plug-in, please override the properties in $.prettyDate.messages. Here, take German localization as an example:
$.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 plug-in updates each selected element every 10 seconds. In this way, "just now" will become "1 minute ago", then "x minutes ago", then "1 hour ago", and so on.
You can disable interval updates by specifying the interval option as "false":
$(function() { $("a").prettyDate({ interval: false }); });
Or set a different time interval, for example: interval: 1000, which updates each page every one second Selected element:
$(function() { $("a").prettyDate({ interval: 1000 }); });
value option reads the ISO8601 date string in the title attribute by default. Override this option to use other properties, for example, a custom "isodate" property:
$(function() { $("a").prettyDate({function() { // "this" 是 DOM 元素return $(this).attr("isodate");} }); });