Click here to Skip to main content
15,917,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have on my index page an input for username and password with a login button.
I have put all the necessary validation in my index.php. I only want my errors tp show on the form is this possible.
PHP
<form name="loginform" id="loginform1" action="unsaved:///?page_id=7&instance=1" method="post">
							<p><label for="user_login1">Username</label>
							<input type="text" name="log" id="user_login1" class="input" value="" size="20" />
							</p>
							<p><label for="user_pass1">Password</label>
							<input type="password" name="pwd" id="user_pass1" class="input" value="" size="20" />
							</p>
							<p class="forgetmenot">
							<input name="rememberme" type="checkbox" id="rememberme1" value="forever" />
							<label for="rememberme1">Remember Me</label> </p>
							<p class="submit">
							<input type="submit" name="doLogin" id="doLogin" value="Log In" />


where can i put the errors message.
Posted
Comments
G4mm4R4y 31-Jul-13 13:50pm    
I would think you could use javascript once the button is pressed and wait ___ seconds and after that stop the loading and say "Form could not be submitted"

Declare your form tag with 'onsubmit' attribute as below

HTML
<form name="loginform" id="loginform1" action="unsaved:///?page_id=7&instance=1" method="post" onsubmit="return validate()">


for a particular element, say input box for User name you can validate inside validate() function of javascript as below

JavaScript
function validate()
{
  var username=document.getElementById("user_login1").val();
  if(username == "")
  {
    alert("User name can't be left blank!");
    return false;
  }
}


Likewise you can validate other members of form as per your validation requirements.Hope this will help you.
 
Share this answer
 
i used php instead. for anyone having the problem you can check the code in action in my site http://www.horsespeedracing.co.za

I am not sure if I am allowed to give my url address. My apologies if I was not suppose to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900