Solved

Need jquery to hide and show label

Posted on 2014-03-19
4
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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…

734 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