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
Shivani JainShivani Jain 

actionFunction not calling controller method

I am calling a controller function from actionFunction. In that function i am checking some field validation and then printing an alert message from javascript . But the function in the controller is not being called . Can anyone suggest some better solution if I want to check wether a field in a list of records is empty or not in controller ?

Thanks in advance :)
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Can you paste your code here
So that someone can help you

-N.J
Vinit_KumarVinit_Kumar
Why you need actionfunction.You can check it in your JS function only and throw a messge if it iss blank .Something like below :-

function validateForm() {
    var x = document.getElementById("{!$Component.fName}");
    if (x == null || x == "") {
        alert("First name must be filled out");
        return false;
    }
return true;
}

<apex:inputText value="{!fname}" id="fName" />
If this helps,please mark it as best answer to help others :)

Ramesh KallooriRamesh Kalloori
Please go through the below code.

<apex:page controller="VisualforceJavascriptDemo">
    <apex:form >
        <apex:actionFunction name="myJSAction" action="{!myJSAction}" rerender="mypanel">
            <apex:param name="firstparam" assignTo="{!myparam}" value="" />
        </apex:actionFunction>

        <apex:outputpanel id="mypanel">
            <apex:outputText value="{!myparam}"></apex:outputText> - <a href="javascript:innerJavascript()">Invoke action here</a>
            
            
            {!myparam }
        </apex:outputpanel>

        <script>
            function innerJavascript(){
                alert('Start invoking vf action!');

                myJSAction('Value is changed by action called by Javascript in Visualforce.');
            }
        </script>
    </apex:form>
    
</apex:page>
public class VisualforceJavascriptDemo{

    public string myparam {get; set;}

    public VisualforceJavascriptDemo(){
        myparam = 'Initial value';
    }

    public PageReference myJSAction(){
        return null;
    }
}

thanks,
RAmesh

Shivani JainShivani Jain
Vinit actually i am displaying some records based on some searching criteria and there is a checkbox infront of each record . I want to send mass email to some selected records . So the validation is to check wether the email is null or having some value . There is no input field email value is coming from database .