How we call a function in .js file for a text box?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sasimca007
    New Member
    • Sep 2007
    • 129

    How we call a function in .js file for a text box?

    Here is the html file

    Code:
    <html>
    	<head>
    		<script language="javascript" type="text/javascript" src="validDate.js"></script>
    	</head>
    	<body>
    		<br><br><br>
    		<center>
    		<form name='frm' method='post'>
    <input type='text' name='test' id='test' value='//' size=5 maxlength=10 onblur='validDate this.form, this.name, this.value)'>
    <input type='button' value='Check' onclick='chk this.form)'>
    		</form>
    		</center>
    	</body>
    </html>
    And here is .js file
    Code:
    function validDate(frm,nam,val)
    {
      alert(val);
    }

    But it is saying Object expected for calling that function, i dont know what object is needed and i am using IE 7.0, can u help me friends it is urgent
  • improvcornartist
    Recognized Expert Contributor
    • May 2007
    • 303

    #2
    Looks like you are missing a "(" in the onblur and onclick.

    Comment

    • sasimca007
      New Member
      • Sep 2007
      • 129

      #3
      how we call a function in .js file for a text box?

      Thanks friend,
      by giving ( also it is showing the error that object is needed. Can anyone help me?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        the this in chk(this.form) is the input element itself, which obviously doesn’t have a .form property.

        Comment

        Working...