Hi
If you are using master page then the server side control id will be changed.
use document.getElementById("ctl00$ContentPlaceHolder1$TextBox1").value=="" to validate the control..
if problem not solved then Check the content page control id by viewing the source & copy the controlid & paste it into getElementById() method.
Here is a sample code..
MasterPage:
<head>
<script type="text/javascript">
function test()
{
if (document.getElementById("ctl00$ContentPlaceHolder1$TextBox1").value==""){
alert("Please enter the text");
return false;
}
else
{
return true;
}
}
</script>
</head>
Child page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return test();" /></td>
</asp:Content>
Note: Instead of writing the whole code to validate a control,you can use required field validator controls by just setting the few properties..