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
Vivekh88Vivekh88 

validation rule for date in visualforce page

Hi,
I need to put a validation on date field which is available on my Visualforce page. How can i achieve that?
I need to enter the date in this format mm//dd/yyyy. If user enters in anyother format it should throw an error.
User-added image
 
VF page:
               <tr>
                <th>
                <b>Date Range:</b> 
                </th>
                <th> 
                From:
                <apex:input type="date" value="{!Startdate}"/>
                </th>
                </tr>
                <tr>
                <th>
                </th>
                <th>
                To: 
                <apex:input type="date" value="{!Enddate}"/>
                </th>
                </tr>
                <tr>

Thanks
Vivek
 
RatanRatan
I suggest use 
 
onkeydown="event.preventDefault();"
 
<apex:input type="date" value="{!Enddate}" onkeydown="event.preventDefault();"/>

event.preventDefault() will prevent the user to type anything then can only select the value using calender view..