function validat()
{
var user = document.getElementById("uname");
var pass = document.getElementById("pass");
if(user.value==""||pass.value=="")
{
alert("No nulls allowed");
return false;
}
else
{
return true;
}
}
<form onsubmit="return validat()" action="Message.html">
<input id="uname" placeholder="User Name" type="text"/>
<br>
<input id="pass" placeholder="Password" type="password"/>
<br>
<button type="submit">Submit</button>
</form>pls i need help the else part in javascript is not working, but always the alert in the function pops even if the values are filled or left empty but else never works.
Aucun commentaire:
Enregistrer un commentaire