1
I have this simple form and a jquery code that automatically fills the email field with the first name of the 'name' field and adds '@dominio.com.br' to form an email address. How do I also make it turn the uppercase characters of the 'name' field into lowercase characters but only in the 'email field'?
jquery:
$(window).load(function(){
$("input[name=nome]").change(function () {
var nome = $(this).val();
var pEspaco = nome.indexOf(' ');
var nomeFinal = nome;
if (pEspaco != -1) {
nomeFinal = nome.substr(0, pEspaco);
}
$("input[name=email]").val(nomeFinal + "@dominio.com.br");
});
});
html:
<form name="campos" method="post" action="<?=$PHP_SELF?>">
<label>
<span>Nome:</span>
<input type="text" name="nome" placeholder="" /><br>
</label>
<label>
<span>Cargo:</span>
<input type="text" name="cargo" placeholder="" /><br>
</label>
<label>
<span>Celular:</span>
<input type="text" name="celular" placeholder="Exemplo: 44 9876 9876" /><br>
</label>
<label>
<span>e-mail:</span>
<input type="text" name="email" placeholder="" /><br>
</label>
<input type="hidden" name="acao" value="enviar" />
<button type="submit" class="envio" title="Enviar mensagem"></button>
</form>