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
Ap30Ap30 

can we call two javascript functions in one onclick in visualforce page

Best Answer chosen by Ap30
Suraj Tripathi 47Suraj Tripathi 47
Hi Ap30,
Greetings!
Yes, you can call two JS Function on one onClick.
<apex:commandButton action="{!save}" value="Save" id="theButton" onclick="myFun1();myFun2()"/>
Use semicolon (';') between both the functions.

Thank you!
Regards,
Suraj Tripathi

All Answers

Suraj Tripathi 47Suraj Tripathi 47
Hi Ap30,
Greetings!
Yes, you can call two JS Function on one onClick.
<apex:commandButton action="{!save}" value="Save" id="theButton" onclick="myFun1();myFun2()"/>
Use semicolon (';') between both the functions.

Thank you!
Regards,
Suraj Tripathi
This was selected as the best answer
Ap30Ap30
Hi Suraj, Below code is not working. nameValidation was working fine.but after adding two functions in onclick , it's not validating now. Also amt validation is not working.send email button is not getting disabled even changed code as per your suggestion. Company Name : Amount :
James MillereJames Millere
Hi, 

Yes, you can call multiple JavaScript functions on a single onClick event in a Visualforce page. You can do this by separating the function names with a semicolon, just like in the example you provided in your previous question.
Eden WheelerEden Wheeler
Sure, I can help you with that. Here's a validation rule that should work for your requirement:
 
AND(
    NOT(ISNEW()),
    ISBLANK(Id),
    User__c = PRIORVALUE(User__c)
)

Explanation:
NOT(ISNEW()) - This condition checks if the record being saved is an update and not a new record creation.
ISBLANK(Id) - This condition checks if the record being saved already has an Id, which means it already exists in the database and is being updated.
User__c = PRIORVALUE(User__c) - This condition checks if the User field on the current record being saved is the same as the User field on the previously saved record for this object.

If these conditions are met, the validation rule will throw an error message. You can customize the error message to suit your needs.
aws online training (https://www.igmguru.com/cloud-computing/aws-certification-training/)
I hope this helps!