4

I am using the apex:inputField to capture the values and and required="true" to set some of the fields mandatory. However, for some buttons like cancel, I don't want it to check the required fields. If I am using apex:commandButton I can use immediate="true" to resolve this. However, since there are many things apex:commandButton can't do I am using standard html and javascript. I find it hard to translate immediate="true" as I saw no difference in the html when debugging. Any suggestions?

4

2 Answers 2

3

There's no direct translation for the immediate attribute, because it only affects server-side validation. In essence, this attribute is evaluated early in the Visualforce transaction lifecycle, before any user-defined code can execute.

While there is a concept of client-side validation in html 5, there's no analogous concept in html 5 for server-side validation, because that's outside the scope of the language definition, and left to the developers of server-side execution, such as salesforce, to define those mechanisms.

1

As noted in the comments and @sfdcfox's answer, the "immediate" attribute affects server logic, and has no direct equivalent in HTML.

However, both actionFunction and commandButton support immediate=true. Have you tried calling an actionFunction (rather than just submitting the form) when you want the "immediate=true" support? Alternatively simulating a click event on a hidden commandButton? Either of those should have the effect you are looking for.

1
  • Thank you for that. I am actually using actionFunction. That will save me some time in implementing this. One thing I am concerned is whether we need to go to server side to verify the mandatory fields though. However, it doesn't seem to be too bad.
    – Lance Shi
    Commented Dec 1, 2014 at 6:32

You must log in to answer this question.

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