Re: need help about inline form validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I think this one is helpful for you.....
Good Luck..

############################ Start Here ##########################
Note:- all code is put in a page. eg:- inlinetest.php
        and run it on the browser...
<script>
  function checkForm() {
name = document.getElementById("name").value;
  email = document.getElementById("email").value;
  comment = document.getElementById("comment").value;
 
  if (name == "") {
  hideAllErrors();
document.getElementById("nameError").style.display = "inline";
document.getElementById("name").select();
document.getElementById("name").focus();
  return false;
  } else if (email == "") {
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
document.getElementById("email").focus();
  return false;
  } else if (comment == "") {
hideAllErrors();
document.getElementById("commentError").style.display = "inline";
document.getElementById("comment").select();
document.getElementById("comment").focus();
  return false;
  }
  return true;
  }
 
  function hideAllErrors() {
document.getElementById("nameError").style.display = "none"
document.getElementById("emailError").style.display = "none"
document.getElementById("commentError").style.display = "none"
  }
</script>
 
<body>
<form onSubmit="return checkForm();" method=post action="myscript.php">
<span class=label>Name:</span><input type=text value="" id=name><br>
<div class=error id=nameError>Required: Please enter your
name<br></div><br>
<span class=label>Email:</span><input type=text value="" id=email><br>
<div class=error id=emailError>Required: Please enter your email
address<br></div><br>
<span class=label>Comment:</span><textarea type=text value=""
id=comment></textarea><br>
<div class=error id=commentError>Required: Please enter a
comment<br></div><br>
<input type=submit value=Submit style="margin-left: 50px">
</form>
</body>
</html>
############################# End Here #############################

--- In php-objects@xxxxxxxxxxxxxxx, birgunj birgunj <birgunjp0071@...>
wrote:
>
> 
> Dear All,
> i want to add inline form validation in my web form.for example when
enter wrong word ,it display the error message near the 
> field box,if enter corrrect work ,it display thanks or good work
near field box.
> if any body any idea or supporting material,please share with us.
>  
> thanks
> 
> 
>       
> 
> [Non-text portions of this message have been removed]
>



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux