+ Start a Discussion
smith indiasmith india 

can anybody give some tasks on validation rules ?

kirankumar vkirankumar v

Hi

please help me how to create a field with flag image if it is true it should show green flag or otherwise red flag

iam new to salesforce can yoy help me..

smith indiasmith india

here true of what means what is the true (error ) condition

kirankumar vkirankumar v

condition

 

 

Eg:-

Contact no should consists of 10 numbers

 

if numbers exceed more than 10 or less than 10 it will displays error. 

error should display in the format of flag(image)

 

If condition is true it shows us green flag

 

otherwise red flag

 

smith indiasmith india

if u get any doubts ask me

-----------------------------------

info:

1st upload 2 small size flags to static resource . (max file size 20kb) .

 

--------------------------------------

<apex:page standardController="Employee__c" extensions="checkmobileno">

<apex:form >
<apex:pageBlock title="employee edit">
<apex:pageBlockButtons >
<apex:commandButton value="save" action="{!save1}"/>

<apex:commandButton value="cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="information" collapsible="false">
<apex:inputField value="{!emp.name}"/></apex:pageBlockSection>
<apex:image value="{!$Resource.greenflag1}" style="height:50px; width:50px" rendered="{!flagcolor}"/>
<apex:image value="{!$Resource.redflag}" style="height:50px; width:50px" rendered="{!flagcolor2}"/>
<apex:outputtext value="mobile no:"/><apex:inputtext value="{!mobileno}"/>

</apex:pageBlock>
</apex:form>
</apex:page>

---------------------------------------------------

and the class is

---------------------

 

public with sharing class checkmobileno

{

             public checkmobileno(ApexPages.StandardController controller)

             {
             emp = new Employee__c();
             flagcolor = true;
             }
//System.debug('length of mobile no-------------------->'+ mobileno.length());

 

public Employee__c emp{get; set;}
public string mobileno{get; set;}
public boolean flagcolor{get;set;}
public boolean flagcolor2{get;set;}

public pagereference save1()
    {
    System.debug('length of mobile no-------------------->'+ mobileno.length());
    if( mobileno.length()!= 10 )
         {
         flagcolor = false;
         pagereference ref = new pagereference('/apex/mobilefieldflagerror');
         flagcolor2 = true;
        return ref;
        }
    else
       {
       flagcolor2 = false;
       flagcolor= true;
      pagereference ref = new pagereference('/apex/mobilefieldflagerror');
      return ref;
      }
 }

}