js验证asp.net控件
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<script language="javascript" type="text/javascript">
function check()
{
var id = '<%=this.txt123.ClientID%>';
var obj = document.getElementById(id);
if(obj.value=="")
{
alert('不能为空')
}
else
{
alert(obj.value)
}
}
</script>
<asp:TextBox ID="txt123" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return check();"/>