Latest web development tutorials

jQuery Prettydate

jQuery Prettydate plug-forms provide strong authentication, allowing the client form validation easier, while providing plenty of customization options to meet application needs. The plug-in bundled with a useful set of validation methods, including URL and email authentication, while providing a user-defined method for the preparation of the API. All binding method using English as the default error message, and has been translated into 37 other languages.

The current version is 1.1.0 plugin.

Download jQuery Prettydate Validation (password authentication) plug .


To use Prettydate plugin, you need with a date in the title of the ISO8601:

<a title="2008-01-28T20:24:17Z"> January 28th, 2008 </a> 
<a title="2008-01-27T22:24:17Z"> January 27th, 2008 </a> 
<a title="2008-01-26T22:24:17Z"> January 26th, 2008 </a>

Then they apply prettyDate methods:

$ (Function () {$ ( "a") prettyDate ();.});

To localize the plug-in, rewriting the property in the $ .prettyDate.messages. Here, the 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 widget is updated once every 10 seconds is selected every element. Like this "just now" becomes "1 minute ago" and then into "x minutes ago" and then into "1 hour ago" and so on.

You can specify the interval option to disable the "false" Update interval:

$(function() { $("a").prettyDate({ interval: false }); });

Or set a different time interval, for example: interval: 1000, updates every second on each of the selected elements:

$(function() { $("a").prettyDate({ interval: 1000 }); });

The default option is to read the title attribute value in ISO8601 date string. Reload this option to use other attributes, for example, a custom "isodate" properties:

$(function() { 
		function() { // "this" 是 DOM 元素
			return $(this).attr("isodate");