sho88 Posted July 19, 2010 Share Posted July 19, 2010 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;" /> Quote Link to comment Share on other sites More sharing options...
Adam Posted July 19, 2010 Share Posted July 19, 2010 What troubles are you having exactly? Quote Link to comment Share on other sites More sharing options...
sho88 Posted July 19, 2010 Author Share Posted July 19, 2010 Basically, when I click on submit, it goes to the next page, the JavaScript code doesn't check the fields first.... how do i get it to check if or if all fields are empty? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.