Solved

Hide show validation message

Posted on 2012-04-10
7
322 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
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 6

Expert Comment

by:kswathi
ID: 37827396
0
 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 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…

758 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

17 Experts available now in Live!

Get 1:1 Help Now