Good morning, I'm creating a form in html and javascript for validation, my idea is to create a successful alert or crash with html and css (cute and etc), but I do not know how I can "call" give a require on that alert that I created, help me? Thanks!
<!DOCTYPE html>
<html>
<body>
<form id="form1" action="">
Nome: <input type="text" name="name" value="Nome"><br>
Sobrenome: <input type="text" name="sname" value="Sobrenome"><br><br>
</form>
<button onclick="takeValue()">mostra valor</button>
<p id="teste"></p>
<script>
function takeValue() {
var x = document.getElementById("form1");
var texto = "";
var i;
for (i = 0; i < x.length ;i++) {
texto += x.elements[i].value + "<br>";
}
document.getElementById("teste").innerHTML = texto;
if(texto == "Nome<br>Sobrenome<br>"){
alert("quero exibir alerta de SUCESSO feito com html e css");
}
else{
alert("quero exibir alerta de ERRO feito com html e csss");
}
}
</script>