+ Start a Discussion
arun rupesharun rupesh 

can any one help me below action function not working properly

Hi,

I wrote one vf page with javascript for checking the maditatory condition in vf page only but it will not work in my org could you please any one help me in my code
<apex:page standardController="Account" extensions="actiontags" id="page">
  <script type="text/javascript"> 
    function validate()
    {
         var name=Document.GetElementByid('page:frm:pb:pbs:nam').value;
         var ph=Document.GetElementByid('page:frm:pb:pbs:ph').value;
        if(name==''){
        alert('name manditatory');
        }else{
         arun();
        }
    }
    </script> 
    <apex:form id="frm">
         <apex:actionFunction name="arun" action="{!insertacc}" rerender="pb"/>
    <apex:pageBlock title="Account information" id="pb">  
        <apex:pageBlockSection columns="1" id="pbs">
            <apex:inputtext label="name"  value="{!name}" id="nam"/> 
            <apex:inputtext label="phone" value="{!phone}" id="ph"/>
            <apex:inputtext label="fax" value="{!fax}" id="fx"/>
        </apex:pageBlockSection>
               <apex:commandButton value="save" onclick="validate();"/>
        </apex:pageBlock>
    </apex:form> 
</apex:page>


public class actiontags {
    public string name{get;set;}
    public string phone{get;set;}
    public string fax{get;set;}
    public actiontags(apexpages.Standardcontroller controller){
       
    }
    public pagereference insertacc(){
         Account a=new Account();
        a.name=name;
        a.phone=phone;
        a.fax=fax;
    insert a;
    return null;
    }
Maharajan CMaharajan C
Hi Arun,

Don't use the Caps Letters:

<script type="text/javascript"> 
    function validate()
    {
         var name=document.getElementById('page:frm:pb:pbs:nam').value;   
         var ph=document.getElementById('page:frm:pb:pbs:ph').value;
        if(name == null || name == '')
        {
        alert("name manditatory");
        return false;
        }
        else{
         arun();
        }
    }
    </script>

Can you please Let me know if it works or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
​Raj