• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Hide show validation message

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
JRockFL
Asked:
JRockFL
2 Solutions
 
Anuradha GoliCommented:
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
 
leakim971PluritechnicianCommented:
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
 
JRockFLAuthor Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leakim971PluritechnicianCommented:
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
 
JRockFLAuthor Commented:
leakim971,

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

 $("label[for=txtBillingFirstName").find("span").show();
0
 
leakim971PluritechnicianCommented:
it will work only for this one... so you will need to create a code for each input.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now