I am implementing JavaScript validations for required fields in a form in an ASP.NET Web Application.

I am getting the ClientID of the control to be validated and extracting the value from it and checking whether it is null:

```
function validate()
{
    if(document.getElementById('<%=textbox1.clientID %>').value=="")
    {
        alert('mandatory');
        return false;
    }
}

```

I am validating on client click of a button. This code works pretty fine when the above function is placed in the same page.

But when I place it in an external file and call it, the code is not working.

It is calling the function in external .js file and throwing an error message like *object not found at document.geteleementByid() line*.