Jump to content

Recommended Posts

if an user doesnt put any word and he click submit , a msg turned on and asks him to re enter cuz the input boxs are empty .. if he re enter just a name another msg (about an empty password box) come and the first msg stays in the page , .. soo i want to clean every error msg after each click on the submit button

 

html :

 

<p id="empty0" style="color:red"></p>

<p id="empty1" style="color:red"></p>

<p id="empty2" style="color:red"></p>

 

<form name="login" action="proc/login_proc.php" onsubmit="return login_valid1()" method="post">

Username:  <input type="text" name="user_name" /><br/>

Password:  <input type="password" name="user_password" /><br/>

<input type="submit" value="Login" /><br/>

</form>

 

 

javascript :

 

function login_valid1()

{

var x=document.forms["login"]["user_name"].value;

var y=document.forms["login"]["user_password"].value;

if((x==null || x=="") && (y==null || y==""))

{

document.getElementById("empty0").innerHTML="you left the username and the password boxes empty , please try again.<br/>";

return false;

}

else if(x==null || x=="")

{

document.getElementById("empty1").innerHTML="you left the username box empty , try again please<br/>";

return false;}

 

else if (y==null ||y==""){

document.getElementById("empty2").innerHTML="you left the password box empty , try again<br/>";

return false;

}

}

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/252305-clean-input-boxes/
Share on other sites

javascript :

 

function login_valid1()

{

var x=document.forms["login"]["user_name"].value;

var y=document.forms["login"]["user_password"].value;

if((x==null || x=="") && (y==null || y==""))

{

  document.getElementById("empty0").innerHTML="you left the username and the password boxes empty , please try again.<br/>";

  return false;

}

else if(x==null || x=="")

{

  document.getElementById("empty0").innerHTML="you left the username box empty , try again please<br/>";

  return false;}

 

else if (y==null ||y==""){

  document.getElementById("empty0").innerHTML="you left the password box empty , try again<br/>";

  return false;

}

}

 

OR if the paragraphs are next to the input boxes:

 

javascript :

 

function login_valid1()

{

var x=document.forms["login"]["user_name"].value;

var y=document.forms["login"]["user_password"].value;

if((x==null || x=="") && (y==null || y==""))

{

  document.getElementById("empty0").innerHTML="you left the username and the password boxes empty , please try again.<br/>";

  document.getElementById("empty1").innerHTML= '';

  document.getElementById("empty2").innerHTML= '';

  return false;

}

else if(x==null || x=="")

{

  document.getElementById("empty1").innerHTML="you left the username box empty , try again please<br/>";

  document.getElementById("empty0").innerHTML= '';

  document.getElementById("empty2").innerHTML= '';

  return false;}

 

else if (y==null ||y==""){

  document.getElementById("empty2").innerHTML="you left the password box empty , try again<br/>";

  document.getElementById("empty1").innerHTML= '';

  document.getElementById("empty0").innerHTML= '';

  return false;

}

}

Link to comment
https://forums.phpfreaks.com/topic/252305-clean-input-boxes/#findComment-1293613
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.