You need to sign in to do that
Don't have an account?

Display error message on Vf page
I am having a VF page which has input text and i made them required by wrapping in outputlabel.
Like this
I would like to display error message when email field is not filled.
I am giving <apex:pagemessages /> in Vf page and below add message in apex class before i upsert contact.
if( Email == null || email== '' ){
ApexPages.addMessage( new ApexPages.Message( ApexPages.Severity.ERROR, 'Please enter Email'));
return null;
}
Still it doesnt work.Please guide me where am i going wrong.
Like this
<apex:pageBlockSectionItem > <apex:outputLabel value="Contact Email"/> <apex:outputPanel layout="block" styleClass="requiredInput"> <apex:outputPanel layout="block" styleClass="requiredBlock"/> <apex:inputtext label="Email" value="{!contactemail}"/> </apex:outputPanel> </apex:pageBlockSectionItem>
I would like to display error message when email field is not filled.
I am giving <apex:pagemessages /> in Vf page and below add message in apex class before i upsert contact.
if( Email == null || email== '' ){
ApexPages.addMessage( new ApexPages.Message( ApexPages.Severity.ERROR, 'Please enter Email'));
return null;
}
Still it doesnt work.Please guide me where am i going wrong.
Looks like you are using the wrong variable name in the check of Controller, it should instead be:
if( contactemail == null || contactemail == '' ){
ApexPages.addMessage( new ApexPages.Message( ApexPages.Severity.ERROR, 'Please enter Email'));
return null;
}
Regards,
Akash.
Thanks,
Srinivas Gupta
Hi Linda,
Can you please post the VF page here.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com