<script type="text/javascript">
 
 function validatePID(inputField , helpText)
   {
    if(inputField.value.length != 9)
      {
        if(helpText != null)
         {
 	      helpText.innerHTML = "Please enter a 9 digit Number";
	      return false;
	     }
	else if( isNaN(inputField.value))
         {
	      if(helpText != null)
	      helpText.innerHTML ="Please enter a number ";
	      return false;
	     }
	else
	    {
	     if(helpText != null)
	     helpText.innerHTML =" ";
	     return true;
	     }
      }	
 
</script>

this is what i am writing in HTML
<input name='PID_help' class='cellData' maxlength="30" style="WIDTH: 302px; HEIGHT: 17px" size=45 title="Enter PPC ID"
tabIndex=4 onblur = "validatePID(this,document.getElementById('PID_help'));">
<span id="PID_help" class="help"></span>

the error i get is object required...

Recommended Answers

All 2 Replies

this is the working version of your code :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
 
 function validatePID(inputField , helpText)
   {
      if(inputField.value.length != 9)
      {
            if(helpText != null)
             {
 	              helpText.innerHTML = "Please enter a 9 digit Number";
	              return false;
	         }
	         else if( isNaN(inputField.value))
             {
	              if(helpText != null)
	              helpText.innerHTML ="Please enter a number ";
	              return false;
	         }
	         else
	         {
	             if(helpText != null)
	             helpText.innerHTML =" ";
	             return true;
	         }
      }	
  }
 
</script>  
</head>
<body>
<input name='PID_help' class='cellData' maxlength="30" style="WIDTH: 302px; HEIGHT: 17px" size=45 title="Enter PPC ID" 
tabIndex=4 onblur = "validatePID(this,document.getElementById('PIDhelp'));"> 
<span id="PIDhelp" class="help"></span> 

</body>
</html>

you missed the function closing curly brackets. indent your code so you dont do such mistakes, also you can not give input name and span id the same thing, i changed it. the rest is your algorithm, which is not accurate yet, i didnt bother to correct it however.

thank's...........
i'll check that out.. and post back...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.