Solved

Hide show validation message

Posted on 2012-04-10
7
333 Views
Last Modified: 2012-06-27
How can I hide and show the validation message below?
There are going to be several elements in the form.

<label for="txtBillingFirstName">First Name:<span class="required">*<strong style="display:inline" class="validate">First Name is required</strong></span></label><input type="text" id="txtBillingFirstName" maxlength="15" />
0
Comment
Question by:JRockFL
[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
7 Comments
 
LVL 12

Assisted Solution

by:Anuradha Goli
Anuradha Goli earned 100 total points
ID: 37827318
place all the elements in div tag
change the display property to block /none to show /hide div tag.
<div id="divcontent">...................</div>

document.getelementbyid("divcontent").display ="block"
0
 
LVL 82

Expert Comment

by:leakim971
ID: 37827365
you may use :
        $("label[for='" + $(this).attr("id") + "']").show();

Open in new window

and :
        $("label[for='" + $(this).attr("id") + "']").hide();

Open in new window

check this page : http://jsfiddle.net/hJXug/
0
 
LVL 8

Author Comment

by:JRockFL
ID: 37827388
leakim971,
I'm just wanting to show/hide this part.
<strong style="display:inline" class="validate">First Name is required</strong>

anuradhay,
Do yo mean like this?
<div id="validateFirstName">
<strong style="display:inline" class="validate">First Name is required</strong>
</div>
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 37827402
so use :
        $("label[for='" + $(this).attr("id") + "']").find("span").show();
and :
        $("label[for='" + $(this).attr("id") + "']").find("span").hide();

check the page updated : http://jsfiddle.net/hJXug/2/
0
 
LVL 8

Author Comment

by:JRockFL
ID: 37827440
leakim971,

Thank you! I'm going to do it slightly different,
Is this syntax correct?

 $("label[for=txtBillingFirstName").find("span").show();
0
 
LVL 82

Expert Comment

by:leakim971
ID: 37827447
it will work only for this one... so you will need to create a code for each input.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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 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)
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…

690 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