0

I want to display an error message when a form is submitted but not all the required fields filled out.

I wanted to use the "required=true" on apex:input tag but because I'm using JS function later in the code (Action functions), the other JS function doesn't work because it "wait" for the required field to be filled.

I decided to use the required with a condition (if a list is not empty - when it's not empty I know I pass all the other JS functions).

<apex:input required="{!acwrapper.size != 0}"

then, I used the

<apex:pageMessages id="messages" ></apex:pageMessages>

to show the error.

My questions are :

  1. How can I change the message for the error? The Error I get Is :

ERROR Error: formPageId:formId:zehutId: Validation Error: Value is required.

  1. How can I style it nicely?

  2. How can I make the field to be painted with red color?

0

I would rather go with JS error. Just create if in function that controls sending logic and change the page a little bit after clicking button when not all of the required fields are populated.

If you really want a SF error. Then to change it you will need to define try catch block in controller and change value of error message.

0

answers for your questions: ERROR Error: formPageId:formId:zehutId: Validation Error: Value is required.

1) take one string variable in controller. when you want to show it just store that message in it and just reRender on the page when you clicks on the button or Any action fucntion if you use(I think you know how to reRender using).

How can I style it nicely?

2) on visual force page use

Styleclass/ Style, class attribute to the ,, any tag. and apply the css to it

using with span tag

<span style="color: red;">{!YourErrorMessage}</span>

using with label tag

<label class='yourclassName'>
       {!YourErrorMessage}
      </label>

<style>
.yourclassName{
color: red;
}
</style>

How can I make the field to be painted with red color?

<style>
    .yourclassName{
    color: green;
    }
    </style>

this will do it for you in red color

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.