Completing an assignment for my university, I created a basic Static Log-In Form using JavaScript and HTML. However, I am facing an issue with the onclick event handler that is not functioning properly. Despite trying various solutions and even attempting to use the 'button' tag, the problem persists. I require assistance in identifying where I may be making a mistake. Below is the code I have written:
<html>
<head>
<title> Test File </title>
<script>
function checkEmailField()
{
if (document.username.sender.value.length < 1)
{
window.alert("Caution! You did not enter your Email");
}
}
</script>
</head>
<body bgcolor="pink">
<table align="center">
<tr>
<td align="center">
<b> <h1> Fill out the form below to log in: </h1> </b>
<form name="logIn" method="post" action="sendMailScriptURL">
<table border="1">
<tr>
<td> <b> Email: </b> </td>
<td> <input type="text" name="username" size="50"> <br> </td>
</tr>
<tr>
<td> <b> Password: </b> </td>
<td> <input type="password" name="password" size ="50"> </td>
</tr>
<tr>
<td> <b> Logging in from: </b> </td>
<td>
<input type="radio" name="from" value="campus"> Campus <br>
<input type="radio" name="from" value="home"> Home
</td>
</tr>
<tr>
<td> <b> I am using: </b> </td>
<td>
<select name="OS" size="1">
<option value="Windows" selected> Windows
<option value="Linux/UNIX"> LINUX/UNIX
<option value="Mac OSX"> Mac OSX
</select>
</td>
</tr>
<tr>
<td> <b> I have: </b> </td>
<td>
<input type="checkbox" name="have" value="Computer"> Computer <br>
<input type="checkbox" name="have" value="Mobile"> Mobile <br>
<input type="checkbox" name="have" value="Printer"> Printer <br>
<input type="checkbox" name="have" value="Scanner"> Scanner
</td>
</tr>
<tr>
<td> <button onclick="checkEmailField()"> Log In </button></td>
</tr>
</table>
</form>
</td>
</tr>
</body>
</html>