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
Ayyagari RameshAyyagari Ramesh 

I want to add javascript validation such that there is a save button which on click if there is are any inputfields which left empty it should throw error. how can i implement this?

Raj VakatiRaj Vakati
Refer this code
 
<apex:page standardcontroller="Account">
  <apex:form >
        <apex:pageBlock >
           Expected price  : <apex:inputText id="inptpriceID"/>
                       <apex:commandButton onclick="validateFunction('{!$Component.inptpriceID}')" value=" Submit Price"/>
        </apex:pageBlock>
  </apex:form>
  
  <!-- Java script starts Here -->
  <script>
   function validateFunction(amountinputID){
       var inputAmount = document.getElementById(amountinputID).value;
         if(inputAmount == ''){
            alert('Please enter amount before submitting price');
         } 
  }
  </script> 
 <!-- java script ends here -->  
</apex:page>

http://sfdcsrini.blogspot.com/2014/09/javascript-validation-in-visualforce.html

http://www.infallibletechie.com/2013/01/how-to-write-javascript-validation-for.html
https://opfocus.com/javascript-validation-in-a-visualforce-page/
https://gist.github.com/the1mattkaufman/6fb978f2de3c7c0cf921a137ed3ac265
http://gokubi.com/archives/using-javascript-to-validate-an-apex-form