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
DayaSZKDayaSZK 

Validation on datepicker

hi all,

 

I am using a datepicker control in visualforce page. I have kept it editable so that user can change time component it.

I need validation on the date time value using javascript, as per the locale . If I change locale on my org , validation should take place as per locale and proper alert message is to be shown using javascript.

 

How can I achieve it using javscript ? I know that visualforce provides some page level validation if invalid date is entered , but i want to show the message in javscript..

 

Thanks,

Dayanand.

 

sforce2009sforce2009

Check if this is useful.

 

<apex:page standardController="Opportunity" sidebar="false" standardStylesheets="false">

    <apex:form >
    
        <apex:inputfield id="oppCloseDate" value="{!Opportunity.CloseDate}"/>
        <script>
            var objCloseDate = document.getElementById("{!$Component.oppCloseDate}");
        </script>
        <apex:commandButton value="Validate" onclick="javascript&colon;return validate()"/>   
    </apex:form>
<script>
function validate()
{
    if('{!yourlocalevalue}' == 'en_us')//YOU HAVE TO SET YOUR LOCALE PROPERTY IN YOUR CONTROLLER/EXTENSEIONS CLASS
    {
        //do your process
        var dateval = objCloseDate.value;
    }
        alert(objCloseDate.value)
    return false;
}
</script>
</apex:page>