+ Start a Discussion
akshay desai 9akshay desai 9 

how to check if lightning field is not null in apex controller i dont want to check this into a vf page

Deepali KulshresthaDeepali Kulshrestha
Hi Akshay,

I've gone through your requirement and you can refer below code to know how to validate in apex controller:VF Page:--->

<apex:pageBlock title="Insert Account"  id="theblock">
            <apex:pageblocksection columns="1" id="fields">
                <apex:inputField value="{!acc.Name}" id="name" /><br/>
                <apex:inputField value="{!acc.Phone}" id="phone" /><br/>

Apex Controller--->

public class ConfirmAccountInsertion {
    public Account acc{get;set;}

    public void saveRecord()
        if((acc.Name!=null || acc.Name!='' ) && (acc.Phone!=null || acc.Phone!='')
             insert acc;

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha