asp.net textbox with java script problem
Posted
by Eyla
on Stack Overflow
See other posts from Stack Overflow
or by Eyla
Published on 2010-03-08T20:58:52Z
Indexed on
2010/03/08
21:06 UTC
Read the original article
Hit count: 187
ASP.NET
|JavaScript
I'm trying to check if asp.net textbox is empty or not using java script. my code working ok but if I enter only numbers will conder it empty so I have either enter letters and numbers or only letters.
Please advice.
here is my code
<script type="text/javascript">
function check(){
var txt = document.getElementById('<%=txt.ClientID%>').value;
//(isNaN(cmbStateHome) == false
if (isNaN(txt) == false) {
alert("Please enter some thing.");
}
else {alert("ok");}
}
}
</script>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<asp:TextBox ID="txtZipCodeHome" runat="server" Style="top: 361px; left: 88px; position: absolute;
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="check()">LinkButton</asp:LinkButton>
© Stack Overflow or respective owner