+ Start a Discussion
Salesforce Developer IndiaSalesforce Developer India 

How to create alert popups when inputText is empty using Apex class?

Hi all,

 

How to create alert popups when inputText is empty using Apex class?

 

can u please help me and give with example....

 

 

Thanks for u r help......

TejTej
                        if( myname == null || myname== '' ){
                                ApexPages.addMessage( new ApexPages.Message( ApexPages.Severity.ERROR, 'Please enter my Name'));
                                return null;            
                        }

  It will show the error message u defined in ur page, u cant create alerts from clss.

 

U need to write javascript function to do the popups.

Prad@SFDCPrad@SFDC

Hi,

 

Try the below Code :

 

In your apex class :

 

public boolean blnAlert{get;set;}

public pagereference Save()

{

           //Check the Value of your Field if it is null or blank than

           blnAlert=true;

          return null;

}

 

 

In Visualforce page

<script>

            if({!blnAlert} == true)

                        alert('Thiis TextBox can not be Blank');

</script>

 

 

did this answer help you.If not than let me know the isse.