Re: need help about inline form validation

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

 



Hi,

I Think it is useful for You..

*******************************************************************
<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 onChange="return checkForm();" method=post action="myscript.php"
onsubmit="return checkForm();">
<span class=label>Name:</span><input type=text value="" id="name"
onchange="return checkForm();"><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
onchange="return checkForm();"><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 onchange="return checkForm();"></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>
*******************************************************************











--- In php-objects@xxxxxxxxxxxxxxx, "Priyantha Gunawardena"
<pgdesigning@...> wrote:
>
> use jquery form validation plugin you can do more with it
> 
> priya
> 
> On Sun, Jul 6, 2008 at 4:42 PM, 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]
> >
> >  
> >
> 
> 
> [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