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
NatrajNatraj 

How to validate a particular field used in fieldset?

Hi All,

 

I am using fieldset in my VF page. The fieldset has add1, ad2,add3,country and postcode fields in it.

When i click the save button, it should check  for any fields values are null and it should throw the error message.. If all fields are filled, then it should save the records.


<apex:pageBlockSection >
 <apex:repeat value="{!$ObjectType.Address__c.Fieldsets.Address_Set}" var="o"  >
  <apex:inputField value="{!addres[o]}" required="{!o.Required}" id="addr"><br/><br/>
   </apex:inputField>                                            
 </apex:repeat>                                               
 </apex:pageBlockSection> 

<apex:commandButton value="Save" action="{!saveadd}"/> 

 

 

public Address__c addres;
    public Address__c getaddres(){      
        addres=new Address__c(Employee_Details__c=this.empDetail.Id);
        return addres;
    }
  
    public PageReference saveadd(){

//I have to do my validation here. if any fields values are null, an error msg should be thrown, orelse it should be saved

         insert addres;
        return null;
}

 

 

If possible give me sample code or do the changes in code above, so tha i can understand it more better.

 

Kindly help me for doing this. Thanks in advance

 

Regards,

Natraj