I've been getting some errors with my javascrript and i can't figure out what is wrong. I just made a simple jQuery statement to check if an email field had a default value and if so, clear the field
Here is the jsFiddle link to the code i am working with: http://jsfiddle.net/qLfBH/ I can't figure out why the jslint is complaining about the line 5 "missing semicolon" and such.
$(document).ready(function () {
var email_default = "Enter your email address...";
$(':input').filter('[type="email"]').attr('val', email_default).focus({
if ($(this).val() == email_default) ;{
$(this).attr('val', ' ');
}
});
});
I have also tried using firebug to debug, but the javascript would not show in the scripts panel- probably because of some syntax error. Any help would be much appreciated.
UPDATE
I edited the code but its still complaining about a "missing semicolon" (see link to fiddle http://jsfiddle.net/qLfBH/3/)
$(document).ready(function () {
var email_default = "Enter your email address...";
$(':input').filter('[type="email"]').attr('value', email_default).focus({
if ($(this).val() == email_default) {
$(this).attr('val', ' ');
}
});
});
FIXED
Ok thanks for the help everyone. I forgot the "function" under the focus. I corrected the errors below and its working :)
$(document).ready(function () {
var email_default = "Enter your email address...";
$(':input').filter('[type="email"]').attr('value', email_default).focus(function () {
if ($(this).val() == email_default) {
$(this).attr('val', ' ');
}
});
});