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

Need to validate inputText as date and Number

I am new bee in SF development. 

I have  apex input fields as

<apex:inputText value="{!Alert_MRR}" >
<apex:inputText style="20%" value="{!Alert_Date}" maxlength="10">


In the validation class

The folling code validates if the alert_MRR is null similarily i want to check for number and date also in serverside

if(Alert_MRR== null ){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'MRR is number.'));
IsValid = false;






In Apex most of the times you dont have to write the validation code. Salesforce provides you with validation rules.

You can use <apex:inputField> in your code and can have a "Validation Rule" for it on your object. So that you will not require to do the validation in your apex code.


Hope this will help!!