I am writing a HTML/CSS/JavaScript program that should show a form that asks for the Full Name and the Birthday Date and then it checks if the input is empty. If the input is empty we should get an alert message.
I have written the following code but I get no alert message. I don't know where the problem is.
function FormValidation() {
var Name=document.getElementById("Name").value;
if (Name == ""){
alert("Please enter your name!");
return false;
}
var BDate=document.getElementById("BDate").value;
if (BDate == ""){
alert("Please enter your BirthdayDate!");
return false;
}
}
body {
background-color: #90AFC5;
color: black;
width: 400px;
}
<form onSubmit="return FormValidation()">
<table class="information">
<tr>
<td><label for="Name">Full Name</label></td>
<td> <input type="text" id="Name" name="Name"><br><br></td>
</tr>
<tr>
<td><label for="BDate">Birthday Date</label></td>
<td><input type="text" id="BDate" name="BDate"><br><br></td>
</tr>
</table>
<input type="submit" style="border-radius:15px;width:40%;background-color:green;text-align:center;color:white" value="Submit" onclick="FormValidation()">
</form>