Hi guys, I'm sure this sounds very silly, but I'm not a JavaScript guy, not as good with the basic fundamentals, however, I'm more of a PHP, HTML, CSS guy, so here's my problem.
At the moment, I'm having troubles with my form validation. Could anyone have a look and see if there's any problem asap please?
Many thanks
Sho.
Javascript.js
// JavaScript Document
window.onload = validation_1();
function validation_1() {
if (document.login.username.value == "")
{
document.getElementById("error_username").style.display = "inline";
document.login.username.focus();
return false;
}
}
form.php
<div class="login">
<h3>Please login to your account.</h3>
<form id="form1" method="post" action="loginAuth.php" id="login" onsubmit="return validation_1(); ">
<div class="form-row">
<span class="label">User Name</span>
<input type="text" name="un" class="adduser" id="username" />
<div id="error_username" style="color:#C00; display:none;">***</div>
<br /><br /><br />
<span class="label">Password</span>
<input type="password" name="pw" class="adduser" id="password" />
<div id="error_password" style="color:#C00; display:none;">***</div>
<br /><br /><br />
<input type="submit" value="Login" style="padding:5px;" />
</div>
</form>
</div>
<img src="img/index.png" title="Home Page" style="float:right; margin-top:-280px; margin-right:80px;" />