3
I wonder how I do to make a system like the onclick
or the click
if it’s jQuery.
When the user presses the key enter
in a form it automatically click the button and send the form with the click
.
I know how to do it but I’d like to learn that method too.
code:
<script>
$("#envia").click(function(){
var campo = {
nome: $("#nome").val(),
email: $("#email").val(),
assunto: $("#assunto").val(),
message: $("#message").val()
};
if(!campo.nome || !campo.assunto || !campo.email || !campo.message){
$.alert({
title: 'Atenção',
content: 'Todos os campos sao obrigatorios!',
});
return;
}
});
</script>
This is the default behavior of a form, without using javascript.
– Juliano Alves
If the last field is one
textarea
you will need to use Javascript.– Diego Souza
my last field and textarea but as I could use to do this I want it to do the same things I programmed in jquery click event
– Leonardo Costa