Possible Duplicate:
textbox empty check using javascript
I have a asp.net button and a asp.net textbox, when I click on button, I want to check if textbox is empty or not but not sure how I can do that,
<div>
<asp:TextBox ID="txtEU" runat="server"></asp:TextBox>
</div>
<div>
<asp:ImageButton ID="button" runat="server" OnClientClick="MyFunction(); return false;" ImageUrl="/myfolder/abc.png" />
</div>
in my JavaScript I am doing,
<script type="text/javascript">
function doWork()
{
if($input[]
not sure how to check if its empty or not, if its empty then I am doing something if not then it should call a code behind method for that button.
Read on the ClientIDMode property to see how element ID are generated in ASP.NET (4.0 and above)
OR
Using Validators will help you handle some of this validation out of the box. One of them is RequiredValidator, which evaluates the value of an input control to ensure that the user enters a value.