-2
Good afternoon, I wanted to keep static the text on the screen inside the div "msgemail", but it disappears soon after the validations. Can someone help me with my code ?
Thank you.
<!DOCTYPE html>
<html>
<head>
<title>teste</title>
<meta charset="UTF-8" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#form_contato').submit(function(){
var er = new RegExp(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/);
var email = $('#txt_email').val();
if( email == '' || !er.test(email) ) { alert('Email inválido'); return false; }
var div = document.getElementById("msgemail");
div.innerText = "Bem vindo " + email;
});
});
</script>
</head>
<body>
<div>
<form action="" id="form_contato">
<label>Email:</label>
<input type="text" id="txt_email"/>
<input type="submit" value="Enviar">
</form>
</div>
<div id="msgemail">
</div>
</body>
</html>
It worked, thank you Rogério.
– Cesar