I have form
with textarea
, I put a placeholder in the input
and it works perfectly, less in textearea
.
<form name="trabalheConoscoFormulario" id="trabalheConoscoFormulario" action="" method="post" onsubmit="return trabalheConoscoForm();">
<div class="grid_210 f-left">
<input type="text" placeholder="nome*" />
<input type="text" placeholder="e-mail*" />
<input type="text" placeholder="telefone" />
<input class="grid_150 f-left" type="text" placeholder="cidade" />
<input class="grid_55 f-right" type="text" placeholder="UF" />
<div class="clear"></div>
<div class="flechaPreta flechaBrancaTrabalhe margin-top-10 cp"></div>
</div>
<div class="grid_210 f-right">
<div class="trabalheConoscoAnexo cp">anexar currículo</div>
<input style="display:none" type="file" class="trabalheConoscoAnexoInput" id="curriculoForm" name="curriculoForm" value="" />
<textarea type="text" id="trabalheConoscoObs" name="trabalheConoscoObs" placeholder="observações">observações</textarea>
</div>
</form>
Jquery:
function add() {
if ($(this).val() == '') {
$(this).val($(this).attr('placeholder')).addClass('placeholder');
}
}
function remove() {
if ($(this).val() == $(this).attr('placeholder')) {
$(this).val('').removeClass('placeholder');
}
}
if (!('placeholder' in $('<input>')[0])) { // Create a dummy element for feature detection
$('input[placeholder], textarea[placeholder]').blur(add).focus(remove).each(add);
$('form').submit(function () {
$(this).find('input[placeholder], textarea[placeholder]').each(remove);
});
}
What's wrong?