function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JeriMorrisJeriMorris 

Want to remove current date link from inputField for a date

My VF page has an inputField component for a date field that represents someone's birthdate. The HTML that gets generated from this includes a link that allows the user to select the current date. For birth dates, it's pretty rare that this link is useful. Is there any way to remove the link, but still keep the rest of the date picker functionality?

For what it's worth, I tried defining this style sheet rule:

   .hideDateFormat a {display:none;visibility:hidden;}

and adding this to the inputField tag:

    styleClass="hideDateFormat"

This successfully hides the date link, but not the square brackets that surround the link, so what I'm left with is a text entry field (which the user an click to invoke the date picker), followed by empty square brackets. I can't figure out how to remove the brackets.

Thanks,

Jeri
Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd
So I was able to figure it out. I just added this to the bottom of my page.

Code:
<style type="text/css">
.dateFormat{
   visibility:hidden;
}
</style>

The problem I see with this is that if you have any other output/input fields that use this styling they won't show up. For me this isn't a issue as the only type of field my page has is a date input field.

All Answers

TehNrdTehNrd
I actually ran into this same issue today so I am curious to a solution as well.
TehNrdTehNrd
So I was able to figure it out. I just added this to the bottom of my page.

Code:
<style type="text/css">
.dateFormat{
   visibility:hidden;
}
</style>

The problem I see with this is that if you have any other output/input fields that use this styling they won't show up. For me this isn't a issue as the only type of field my page has is a date input field.

This was selected as the best answer
JeriMorrisJeriMorris
TehNrd,

Yeah, I figured that out too, and realized that it had the limitation you described -- it causes the link to disappear for all date inputFields on the page. That's why I tried playing with my own CSS class, which I can use for specific date fields only. Using that class, I can get the link to disappear, but I can't figure out how to get the class applied to the span that contains the square brackets around the link.

I'm new to VisualForce and I haven't written any custom components yet. Is there a way to build a solution to this problem using custom components?

Jeri.
Gary ButlerGary Butler
Hi all, I know this is an old link, but here is a solution I found that does not affect the entire page...  

Create a Visualforce Component (I called mine hideDateLink.vfc) that contains
<apex:component access="global">
	<style>
		div.hideCurrDate span.dateInput span.dateFormat{ display:none; }
	</style>
	<div class="hideCurrDate">
	    <apex:componentBody />
	</div>
</apex:component>
then in the VFP, simple place the apex:inputfield between component tags as shown here
<c:hideDateLink>
    <apex:inputField value="{!contact.Birthdate}" required="true" style="width:120px"/> 
</c:hideDateLink>
Robert DrollingerRobert Drollinger

Thanks Gary Butler! Your solution worked perfectly for me. The other solutions were still leaving me with huge columns with empty space.  I tried giving a thumbs up but it wouldn't let me.

Himanshu Nimje 12Himanshu Nimje 12
<style type="text/css">
        .dateFormat{
             visibility:hidden;
        }
        .anotherchildsectionitem fieldset {
            display: inline-block;
        }
    </style>