<script language="javascript" type="text/javascript">
document.onclick = check;
function check(e)
{
var target = (e && e.target) || (event && event.srcElement);
if(target.id!="txt")
{
if(document.getElementById("txt").value=="")
{
document.getElementById("txt").value="Enter Text Here";
document.getElementById("txt").style.color='ActiveBorder';
}
}
if(target.id=="txt")
{
document.getElementById("txt").style.color="Black";
if(document.getElementById("txt").value=="Enter Text Here")
document.getElementById("txt").value="";
}
}
function Validate()
{
if(document.getElementById("txt").value!="Enter Text Here" && document.getElementById("txt").value!="")
return true;
else
return false;
}
</script>
<asp:TextBox id="txt" runat="server" Text="Enter Text Here" style="color:ActiveBorder;"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="asdf" OnClientClick="javascript:return Validate();" />
</div>
Tag: Handling click event for TextBox in asp.net, text box wrapper event using javascript, textbox events using javascript in asp.net
No comments:
Post a Comment