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
Vivek ManchandaVivek Manchanda 

How to apply validation on inputtext on commandbutton click?

Hi All

I have made a page in which I have around 2 section , first section  contains the Account Information ,Second Section contain the Contact information , I am calling this information trough Custom Controller . I have also made EDIT button on both the session so when ever I click on Edit button I get the section in edit mode ,and I am also able to save this new Information through edit mode .

by writing the "<apex:commandButton  value="Save"  />"

By only writing this code I am able to save the changes which I have made in edit mode .

Now the problem is that I am not able to do any type of VALIDATION in the text input ..For validation i am using
"<apex:inputText  id="firstName" styleClass="std"  value="{!firstName}"/>
                        <apex:outputPanel id="fnError" layout="block" style="color:red" rendered='{!IF(LEN(firstName)>0,false,true)}'>Please enter First Name</apex:outputPanel>"

Can any one Help me that how I can do that .

Thanks
Vivek Manchanda
Ron HessRon Hess
you can put validation formulas on the field in the App itself (using setup, app setup, customize, contact,...)  ,
no need to do that much work in the VF page, it should just work.
Vivek ManchandaVivek Manchanda
Thanks Ron

But I am not able to get you what you want me to do .

Or

I don't need  the output panel for the validation .
See the thing is I am getting the Error , but I get this when I again click on that Edit Button ..

So I don't need that the thing is I need to show this Error when first time I click on the save button .

But on clicking on edit button It is saving the Blank value and when I again Click on Edit It show me the Msg which I have wrote in output panel .


Thanks
Vivek Manchanda

Vivek ManchandaVivek Manchanda
Sorry

"But on clicking on save button It is saving the Blank value and when I again Click on Edit It show me the Msg which I have wrote in output panel ."

Thanks
Vivek Manchanda

Ron HessRon Hess
I don't understand,

are you using validation formulas on the contact fields, at the database level where they belong?

OR

are you writing your own validation formulas using outputPanel and IF() formulas on the visualforce page?


please see this help topic
https://na5.salesforce.com/help/doc/en/fields_useful_field_validation_formulas.htm#ContactValidationRules

I would urge you to try these formulas, and thereby avoid writing your own business logic inside the re-rendered attribute expression.