title: How can i call a function, which is present in JavaScript object from an on-click event of a button?
body: <p>see the js code first:</p>
  
  <pre><code>let javascript = {
  checkValidations: function(){
      let firstName = document.getElementById("firstName");
      let lastName = document.getElementById("lastName");
      let age = document.getElementById("age");
      let flag = 0;
      if(firstName.value==null || firstName.value==""){
          document.getElementById("firstNameError").innerHTML = "First name cannot be blank"; 
          flag = 1;
      }
      if(lastName.value==null || lastName.value==""){
          document.getElementById("lastNameError").innerHTML = "Last name cannot be blank";   
          flag = 1;
      }
      if(Number.isNaN(age) || age==null || age=="" || Number(age)&lt;18 || Number(age)&gt;120){
          document.getElementById("ageError").innerHTML = "Age is not in required format";
          flag = 1;
      }
      if(flag==0){
          // save values
      }
  };
  </code></pre>
  
  <p>And now I am trying to call this function from a button event:</p>
  
  <pre><code>&lt;button class="btn btn-success" onclick="javascript.checkValidations"&gt;
  </code></pre>
  
  <p>Its not working ! I am doing this just to provide modularity to my code. </p>
  
  <p>Can you tell me a way, how to achieve this ?</p>