Solved

Need jquery to hide and show label

Posted on 2014-03-19
4
335 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
ID: 39940749
<script>
$(function() {
     $("#<%=txtSqFT.ClientID%>").change(function(){
          $("#<%=lblSqFt.ClientID%>").show()
     })
})
</script>

Open in new window

0
 

Author Comment

by:mgmhicks
ID: 39942454
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
ID: 40144986
Javascript is case sensitive:

txtSqFT != txtsqft...

Cheers
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40145007
3 months later...

Check txtSqFT and lblSqFt are the correct case.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net - Project Software to help the Developer 7 33
VB.NET 2008 Populate DataModel with DataTable 44 28
jquery auto complete 11 15
jquery datepciker end date add 6 days 6 33
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

816 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

11 Experts available now in Live!

Get 1:1 Help Now