Skip to content

Instantly share code, notes, and snippets.

@steveclarke
Created March 30, 2012 01:26
Show Gist options
  • Save steveclarke/2245560 to your computer and use it in GitHub Desktop.
Save steveclarke/2245560 to your computer and use it in GitHub Desktop.
$ ->
# Handle focus on the Contact Form
$('#email').focus -> $(this).val('') if $(this).val() == 'E-mail Address'
$('#email').blur -> $(this).val('E-mail Address') if $(this).val() == ''
$('#phone').focus -> $(this).val('') if $(this).val() == 'Telephone Number'
$('#phone').blur -> $(this).val('Telephone Number') if $(this).val() == ''
$('#message').focus -> $(this).val('') if $(this).val() == 'Message'
$('#message').blur -> $(this).val('Message') if $(this).val() == ''
$(function() {
$('#email').focus(function() {
if ($(this).val() === 'E-mail Address') {
return $(this).val('');
}
});
$('#email').blur(function() {
if ($(this).val() === '') {
return $(this).val('E-mail Address');
}
});
$('#phone').focus(function() {
if ($(this).val() === 'Telephone Number') {
return $(this).val('');
}
});
$('#phone').blur(function() {
if ($(this).val() === '') {
return $(this).val('Telephone Number');
}
});
$('#message').focus(function() {
if ($(this).val() === 'Message') {
return $(this).val('');
}
});
$('#message').blur(function() {
if ($(this).val() === '') {
return $(this).val('Message');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment