Solved

Need jquery to hide and show label

Posted on 2014-03-19
4
333 Views
Last Modified: 2014-06-19
I Have a label called lblMyErr and by default is hidden.  I have a gridview called mygrid and a template textbox called txtSQFT.   What I need is a jquery function I can use on the txtSQFT
textbox, so that if the textbox has been changed it will run this jquery function and make visible the lblmyerr.

The issue is I have a gridview control that is edit mode for all rows.  So I cant use row updating or something like that.  I need a jquery to run on the textbox textchanged event.

thanks

 
<asp:TemplateField HeaderText="Sq Ft" HeaderStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <asp:Label ID="lblSqFt" runat="server" Text='<%# Bind("SqFt") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtSqFT" runat="server" Text='<%# Bind("SqFt") %>' OnTextChanged="sqft_TextChanged"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Numbers Only"
                                    Text="*" ValidationExpression="^(?:\d+(?:\.\d{1,2})?)?$" ControlToValidate="txtsqft"></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            
                        </asp:TemplateField>

Open in new window

0
Comment
Question by:mgmhicks
  • 2
4 Comments
 
LVL 58

Expert Comment

by:Gary
Comment Utility
<script>
$(function() {
     $("#<%=txtSqFT.ClientID%>").change(function(){
          $("#<%=lblSqFt.ClientID%>").show()
     })
})
</script>

Open in new window

0
 

Author Comment

by:mgmhicks
Comment Utility
thanks Gary, I'm getting txtsqft does not exist.  I am using a master page if that changes the script at all.
0
 
LVL 4

Expert Comment

by:smeghammer
Comment Utility
Javascript is case sensitive:

txtSqFT != txtsqft...

Cheers
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
Comment Utility
3 months later...

Check txtSqFT and lblSqFt are the correct case.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now