I recently started with this and I'm having a problem with my code. I want to make a simple login form and I am having the problem that I can not perform the validation if I use the form tag, otherwise the validation can be done but I lose the design I get with the form. The code that I have is the following:
In my HTML
<form id="formulario" name="formulario">
<center><img id="img" src="login.png" alt="iniciar sesión"/></center>
<label id="lbl-inicio"><b>Iniciar Sesión</b></label>
<br/> <br/>
<hr>
<input type="text" placeholder="Nombre Usuario" name="usuario" id="usuario"
ng-model="form.usuario"/>
<br/>
<input type="password" placeholder="Contraseña" name="contraseña"
id="contraseña"/>
<br/>
<input type="submit" class="btn btn-info" id="iniciar" onclick="iniciar()"
value="Iniciar Sesión"/>
<input type="button" class="btn btn-danger" id="cancelar"
onclick="cancelar()" value="Cancelar"/>
</form>
In my JS
function cancelar(){
document.getElementById("usuario").value = "";
document.getElementById("contraseña").value = "";
}
function iniciar(){
if (document.getElementById("usuario").value=="admin" &&
document.getElementById("contraseña").value=="admin"){
alert("Sesión iniciada");
}
else {
alert("Error de autenticación");
document.getElementById("usuario").value = "";
document.getElementById("contraseña").value = "";
}
}