+ Start a Discussion
umair ayazumair ayaz 

unknown property error please help

Hello I am trying to validate account name. I want to check if the account with same name exists so i have written controller class method to check it but i am not able to call it from visuaforce page.
Following is my visualforce page
<apex:page controller="AddAccountController" tabStyle="Account" standardStylesheets="false" showHeader="false" sidebar="false">
        .myFormStyle {
        background-color: #D3D3D3;
        border:3px outset black;
        border-top:2px dotted black;
        border-left:2px dotted black;
     function AccountCheck() {
         var x = "{!checkAccount}"
    <apex:form styleClass="myFormStyle">
            <apex:pageBlock title="Add Account">
                <apex:pageBlockButtons location="top" >                   
                    <apex:commandButton value="Save" action="{!save}" reRender="accountList"  />
                    <apex:commandButton value="Cancel" action="{!cancel}" />
                <apex:pageBlockSection title="Account Details" columns="1">            
                    <apex:inputField id="accountName" value="{!act.name}" onblur="AccountCheck()"/> 
                    <apex:inputField value="{!act.site}"/> 
                    <apex:inputField value="{!act.type}"/> 
                    <apex:inputField value="{!act.accountNumber}"/>              
            <apex:pageBlockTable value="{!Account}" var="acc" id="accountList" styleClass="tableBorder">              
                <apex:column value="{!acc.Name}" styleClass="innerTableBorder" />            
                <apex:column value="{!acc.Site}" styleClass="innerTableBorder" />               
                <apex:column value="{!acc.type}" styleClass="innerTableBorder" />               

Here on its my Controller
public class AddAccountController {
    public List <Account> account=new List <Account>();
    public Account act{get;set;}
    public integer counter {get;set;}
    public AddAccountController() {       
        act = new Account();
    public List <Account> getAccount() {
        account = [SELECT Id, Name, Site, Type FROM Account order by createddate desc limit 20];
        return account;
    public PageReference cancel() {
        return null;
    public PageReference save() {
        system.debug('act name:' + act.name + ' = ' + act.accountNumber);
        upsert act;
        return null;
    public Integer checkAccount(){
        String accountName =System.currentPageReference().getParameters().get('accountName');
        account = [SELECT Id, Name, Site, Type FROM Account WHERE Name = :accountName];
            return counter;
        return counter;
Below is the error that i get please tell me why i get this error.
Unknown property 'AddAccountController.checkAccount'
I want it to call the checkAccount() method  from my javasccript function that i am calling from onblur method. So please experts help a newbie
Raj VakatiRaj Vakati
Hi ,

You need to use Action function or other Salesforce javascript option. the way you are invoking the code was wrong.
You can not call the Salesforce controller action directly into the javascript . 

Thanks ,