Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

problem in function calling in javascript

I have written a simple java script in an external .js file named indexcheck.js

function check()
{
if(document.form1.txt.value == "")
{
alert("User ID cannot be blank")
return
}
}

In the html page i have i have included it under the HEAD tag using the code:

<script type="text/javascript" src="indexcheck.js"></script>

in a form named as form1 i gave a button as:

<input type="button" name="Button" value="Submit" onClick="check()">

But my code is not working.
Can anybody tell me the proper code or can u please tell me how can i call a function written in another file on the occurring of an event.
please help me
[730 byte] By [sudip_124] at [2007-11-11 8:17:52]
# 1 Re: problem in function calling in javascript
this works:
document.forms[0].txt.value

or

document.forms['xxx'].txt.value
with
<form name="xxx">
ErgonomicTimes at 2007-11-11 23:34:49 >
# 2 Re: problem in function calling in javascript
^
Thank you. It is working
sudip_124 at 2007-11-11 23:35:49 >