button in JAvaScript function validate(){ var uname=document.getElementById("username"); var passwd=document.getElementById("pass"); if(uname.value.trim()=="" ){ alert("Blank Username not allowed"); return false; }else if(passwd.value.trim()==""){ alert("Blank password not allowed"); return false; }else if(passwd.value.trim().length()
<body>
<form onsubmit="return validate();" action="message.html">
<input id="username" type="text" placeholder="Username">
<br><br>
<input id="=pass" type="password" placeholder="Password">
<br>
<br>
<button type="submit">Submit</button>
</form>
</body>
Aucun commentaire:
Enregistrer un commentaire