jQuery Plugin for using default value as label

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Wrote a little plugin for using the default value in text elements as label, you know. Look at the right hand side in the newsletter form for an example.


$.fn.label = function(options){

	var default_settings = {
		clearLabels : true
	};

	var settings = $.extend(default_settings, options);

	return this.each(function(){
		var elm = $(this);
		if($(this).val().length > 0) {
			$.data(elm, 'default', $(this).val());
			elm.focus(function(){
				if($(this).val() == $.data(elm, 'default')) {
					$(this).val('');
				}
			}).blur(function(){
				if($(this).val() == '') {
					$(this).val($.data(elm, 'default'));
				}
			});

			if(settings.clearLabels) {
				$(this.form).submit(function(){
					if($(this).val() == $.data(elm, 'default')) {
						$(this).val('');
					}
				});
			}
		}
	});
}


iPhone Enabled Mobile Web

We are now iphone enabled! As a first step towards full mobile compability, starting today, FrontEndBook.com is also available through your iPhone or iPod Touch. I found this great WordPress plugin/theme bundle: iWPhone.

I am writing a longer article on how I believe iPhone will change the mobile web, subscribe to our RSS-feed in order to read the article when it is ready for publishing.

Update: Read our longer post on how iPhone and Android will change the way we use the web.


Contact

You are more than welcome to contact us if you would like to discuss anything regarding the blog.

About

Front-End Book is run and primarily written by Mattias Hising, an experienced Lead Developer from Uppsala, Sweden. I try to focus my efforts on Front-End related issues, as I find the problems to solve are more complex and interesting than the ones in traditional back-end development.

Twitter | GitHub | FriendFeed | LinkedIn | StumbleUpon | Facebook | Delicious