Salesforce

Salesforce

How to write Javascript validation for Visualforce page?

Sample Code: Visualforce Page: <apex:page controller="Sample" ><!-- Javascript -->    <script type="text/javascript">    function validate()    {        if(document.getElementById('{!$Component.frm.pb.pbs.pbsi1.nam}').value == '')        {            alert("Account name is mandatory");        }        if(document.getElementById('{!$Component.frm.pb.pbs.pbsi2.extid}').value == '')        {            alert("External id is ....

Salesforce

Sample calculator using Visualforce page and Apex in Salesforce

Sample code: Visualforce page: <apex:page controller="Sample"> <apex:form >     <apex:pageBlock > <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel value="Value 1"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:inputText value="{!val1}"/> </apex:pageBlockSectionItem>                           <apex:pageBlockSectionItem > <apex:outputLabel value="Value 2"/> </apex:pageBlockSectionItem> ....