Solved

Hide show validation message

Posted on 2012-04-10
7
323 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
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.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now