Hi
Sandeep's answer is correct. But strictly if you want to have javascript to do this then here is the example.
You should not challenge any one, because there nothing you can say impossible.
If you are using master and client then you need to have the scripts at Master page's header, otherwise need to inject using the RegisterClientScript method.
so as an example have this at the site master's header section..
As from there the text box and labels not accessible (which are in the content page) you need to get the ID and search for it
<script type="text/javascript"">
function validateThreeBoxes(boxID1, labelID1, boxID2, labelID2, boxID3, labelID3) {
if (document.getElementById(boxID1).value == "") {
document.getElementById(labelID1).style.visibility = "visible";
}
if (document.getElementById(boxID2).value == "") {
document.getElementById(labelID2).style.visibility = "visible";
}
if (document.getElementById(boxID3).value == "") {
document.getElementById(labelID3).style.visibility = "visible";
}
}
</script>
The aspx page can have like this....
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Text1 Should Not be Empty" style="visibility:hidden"></asp:Label>
</div>
<div>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="Text2 Should Not be Empty" style="visibility:hidden"></asp:Label>
</div>
<div>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Label ID="Label3" runat="server" Text="Text3 Should Not be Empty" style="visibility:hidden"></asp:Label>
</div>
<input type="button" id="Button1" runat="server" value="Button1" />
At the page load event...
protected void Page_Load(object sender, EventArgs e)
{
string textbox1Id = TextBox1.ClientID;
string label1Id = Label1.ClientID;
string textbox2Id = TextBox2.ClientID;
string label2Id = Label2.ClientID;
string textbox3Id = TextBox3.ClientID;
string label3Id = Label3.ClientID;
Button1.Attributes.Add("onclick", "validateThreeBoxes('" + textbox1Id + "','" + label1Id + "','" + textbox2Id + "','" + label2Id + "','" + textbox3Id + "','" + label3Id + "');");
}
now you can see it working..