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
anu_karthianu_karthi 

Field validations in visualforce page

HI  Everyone,

 

I have been in the process of doing an app where i was working with visualforce pages......So i want to do field validations before i save the record .......So    validations  what  i expect   is when any child field is dere(field looked from other object)  i am supposed to fill that child related fields ... AS i have created a link beside that field which takes me to the child object where can i fill    the child related fields and come back to the original page .....So if the user not filling the child related field,(by going thru the link)

        

den i should give a error message that is wat i expect....and one more thing when i click save this validations + save action to be done ...............So i have to override the functionality of  save button.................So plz tel

 

 me how can i do that...............

 

 

                                                                                                                             Thanks in advance,

                                                                                                                                       Anu...........

Nick1746323Nick1746323

No need to override the save action, you can create validation rules as normal on the relevant object. They will always be checked when clicking save in a visualforce page. you'll need a <apex: pageMessages/> somewhere in the page in order to see any errors. Or, if thats not possible you could write an apex trigger to do the validation.

 

But if you really want to override the save button, its not too hard. you need to write an apex method in your controller/extension, and then in the VF page set the action of a commandButton to that method. Have a read in the documentation about "Defining Action Methods".