validate in html code example
Example 1: html form validation
<form action="">
<label for="name">Username</label>
<input id="name" type="text" required />
<label for="Email">Email</label>
<input id="Email" type="text" required />
</form>
Example 2: javascript login validation
<script language = "JavaScript">
function validate() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username == null || username == "") {
alert("Please enter the username.");
return false;
}
if (password == null || password == "") {
alert("Please enter the password.");
return false;
}
alert('Login successful');
}
</script>