I am making a form where I have two fields that are required, in this case they are name and email. What happens is that these fields must be full, but even if they are not, if I press the send button, the alert sent will jump. What I need to do is that if these fields are not full, do not show this sent alert, when you click the send button. Together code.
They are already set with the required attribute, but what happens is that if you press the send button it sends one, what you need is to validate if the email fields and names are valid and then when you click send send sent. It would be something as long as those fields are not full, block the send button. Thank you.
<form action="no_existe.html" method="get">
<fieldset>
<legend>Datos</legend>
Nombre y apellido (máximo 20 caracteres) <input type="text" placeholder="Ingrese su nombre" maxlength="20" required> <br>
Correo <input type="email" placeholder="Email" required> <br>
<input type="submit" class="button" name="enviar" onclick="hizoClick()" value="Enviar">
<script>
function hizoClick() {
alert("Enviado");
}
</script>