I am using a VF page having a custom controller. For simplicity, I am using 2 date fields - fromDate
and toDate
which belongs to a custom object.
There is a command button named Search on VF page which when clicked calls a javascript function to check if fromDate
is greater than toDate
.
Now the problem is when I enter "adbcg" (some garbage) in fromDate
and some legitimate date in toDate
and hit the search button, javascript function is getting called and not the system validation for date field. I first want the system validation to fire as in the fromDate
should be highlighted to give Invalid date error.
Any help highly appreciated.
VF page---
<apex:page controller="FinancialSearchController" showheader="true">
<script type="text/javascript">
function checkValidations() {
....
...
}
<script type="text/javascript">
<apex:form id="FinancialDataSearchForm" >
<apex:outputLabel value="{!$ObjectType.Financial_Search__c.fields.fromDate__c.label}" for="priority"/>
<apex:inputField id="fromDate" value="{!FSInputRecord.fromDate__c}"/>
<apex:commandButton value="Search" onclick="checkValidations(); return false;" reRender="primaryResultsPanel, additionalResultsPanel"/>
</apex:form >