Commit 1da61ee1 by Javier Ferreira

Initial commit

parent 46ea86b3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ejercicio 3</title>
<style>
.errormsg{
color: red;
display: none;
}
</style>
</head>
<body>
<form action="mailto:me@fakeemail.com" id="formx">
<fieldset>
<legend>Personal details</legend>
<p>
<label>
Full name:
<input type="text" name="fullname" id="fullname">
</label>
</p>
<p class="errormsg" id="nameerrormsg">Ingrese su nombre</p>
<p>
<label>
Street Address:
<input type="text" name="streetaddr" id="streetaddr">
</label>
</p>
<p class="errormsg" id="addrerrormsg">Ingrese su direccion
</p>
</fieldset>
<input type="submit" value="Submit it!">
</form>
</body>
<script>
document.querySelector('#formx').addEventListener('submit', ()=>{
const nameError = document.querySelector('#nameerrormsg');
const streetError = document.querySelector('#addrerrormsg');
if(document.querySelector('#fullname').value === ""){
nameError.style.display = 'block';
}else{
nameError.style.display = 'none';
}
if(document.querySelector('#streetaddr').value === ""){
streetError.style.display = 'block';
}else{
streetError.style.display = 'none';
}
});
</script>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment