+ Start a Discussion

Field validation Through ajax.

I am creating a form through visualforce  (consist of three pages), i want to validate some of  my fields ( e.g.- account name is unique or not )on the first page itself before clicking submi button(which is on third page).Can i implemnt such functionalities using ajax.
If yes please guide me.
You accomplish this using AJAX like functionality. I think it is a combination of <apex:inputText>, <apex:actionFunction>, and your controller (apex code associated to your page).

If you want the validation logic to be executed when a user steps of an <apex:inputText> component (for example), I would

(a) in the VF page, define the <apex:inputText> to let the user enter the account name,
(b) in the VF page, define the <apex:actionFunction>
(c) modify the <apex:inputText> and set the onBlur eventhandler to execute the name of the function defined in the <apex:actionFunction>. In turn this will execute the apex method defined in the actionFunction. All combined, when a user steps off the inputText box, the onBlur event is called, which executes the actionFunction javascript method which calls the apex code to perform the logic. You also can specify the status and reRender attributes on the actionFunction component to get additional benefits for displaying the results.

Check out the Visualforce Reference Guide for more details on those components: http://www.salesforce.com/us/developer/docs/pages/index.htm