Hi I have following code for visual force and apex controller to render the checkbox. I have marked the checkbox as required="true". When I try to submit the page it give me cryptic error message.

Error Message:

j_id0:SPE: Validation Error: Value is required.

How do I modify this error message?

<apex:selectCheckboxes value="{!RegPeriod}" required="true" id="RegPerdId">
                    <apex:selectOptions value="{!RegistrationPeriod}"/> 

Apex Controller:

public List<String> regPeriod = new List<String>();
    public List<String> getRegPeriod(){
        return regPeriod;
    public void setRegPeriod(List<String> RegPrd){

public List<SelectOption> RegistrationPeriod {
        get {
            List<SelectOption> listOfRegPeriod = new List<SelectOption>();
            for(S_Period__c certiPeriod : listPeriod) {
                listOfRegPeriod.add(new SelectOption( certiPeriod.Id, certiPeriod.Name));
        return listOfRegPeriod;
  • 1
    Have you tried providing a label?
    – sfdcfox
    Jan 19, 2015 at 21:39
  • I find it helpful to handle my own required field checking, so that I can respond with a complete error message, without the "j_id0:SPE" that gets added by the built-in validation ...
    – user735
    Jan 19, 2015 at 21:58

1 Answer 1


Specify a label attribute for your input elements. Example provided below.


public class reqchk {
    public reqchk() {
        values = new String[0];
    public String[] values { get; set; }
    public SelectOption[] getOptions() {
        SelectOption[] results = new SelectOption[0];
        for(String item: 'Value A;Value B;Value C;Value D'.split(';')) {
            results.add(new SelectOption(item, item));
        return results;


<apex:page controller="reqchk">
        <apex:pageMessages />
        <apex:selectCheckboxes label="Value Selections" required="true" value="{!values}">
            <apex:selectOptions value="{!options}" />
        <apex:commandButton value="Submit" />

Note that you won't see the label unless you include the element in a page block, however... but the error message will be correct.

  • Thanks for the reply. :) After updating it with label the error message is: Value Selections: Validation Error: Value is required. Cant we modify whole message?
    – JavaAster
    Jan 19, 2015 at 21:50
  • 1
    For anything more advanced, you'll have to roll your own with ApexPages.addMessage, and do the validation in controller code. You'll lose the ability to "highlight" the field with a required mark automatically, so you'll also need to add more code to make it look required. Also, consider that the default message is automatically translated (except the label itself) for all languages. And if your label uses $Label, it too can be multilingual.
    – sfdcfox
    Jan 19, 2015 at 22:03
  • For the time being this seems fine.
    – JavaAster
    Jan 19, 2015 at 22:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .