I'm developing a WordPress plugin, and I was using a simple script to return an empty value to a text field if its value matched the placeholder value; it did this on submit. Then when I switched to the jQuery Ajax Form plugin, this no longer worked. Here's the original script:
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('ssfa-placeholder');
input.val(input.attr('placeholder'));
}
}).blur().parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
From lines 14 on is where it does its real work. But now that I'm using the Ajax form plugin, this no longer works. Here's my basic code for the Ajax form:
Now I assume I'll have to pass the placeholder stuff in a beforeSerialize function, but I'm not sure where to begin. To be clear, I do not want the placeholder value to be saved as the input fields' value on ajax form submit.