title: onClick from button to function
body: <p>This is a work in progress (a calculator and some other stuff), but what I'm trying to do at the moment is whenever you type in some number into the results of the calculator, and you press "+" the onclick will call checkValidity which will determine if what you typed in was integer or not integer. It will send an alert saying integer or not an integer. My issue is that the onclick won't do anything. I tried emptying the checkValidity function of everything but alert("test); and it still won't work. Could someone please explain what I'm doing wrong?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;head&gt;
        &lt;script type="text/javascript&gt;"&gt;
           function checkValidity()
           {
              var Calculator = document.getElementById("Calculator")
           if (Calculator.Result.value === parseInt(test, 10))
              {
              alert("Integer!");
              }
              else
              {
              alert("Not an integer, press C");
              }
           }
        &lt;/script&gt;
        &lt;form name="Calculator"&gt;
           First name:
              &lt;br&gt;
                 &lt;input type="text" name="firstname"&gt;
              &lt;br&gt;
           Last name:
              &lt;br&gt;
                 &lt;input type="text" name="lastname"&gt;
              &lt;br&gt;
           Student ID:
              &lt;br&gt;
                 &lt;input type="text" name="ID"&gt;
              &lt;br&gt;
           Biography:
              &lt;br&gt;
                 &lt;textarea maxlength=30 rows="2" cols="30"&gt;
                 &lt;/textarea&gt;
              &lt;br&gt;
           Result:
           &lt;table border="1" style="width:100%"&gt;
              &lt;input type="text" name="Result" size="12"&gt;
              &lt;tr&gt;
                 &lt;td&gt;&lt;Input type="button" Name="zero" Value="0" OnClick="Calculator.Result.value += '0'"&gt; &lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="one" Value="1" OnClick="Calculator.Result.value += '1'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="two" Value="2" OnClick="Calculator.Result.value += '2'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="three" Value="3" OnClick="Calculator.Result.value += '3'"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                 &lt;td&gt;&lt;Input type="button" Name="four" Value="4" OnClick="Calculator.Result.value += '4'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="five" Value="5" OnClick="Calculator.Result.value += '5'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="six" Value="6" OnClick="Calculator.Result.value += '6'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="seven" Value="7" OnClick="Calculator.Result.value += '7'"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                 &lt;td&gt;&lt;Input type="button" Name="eight" Value="8" OnClick="Calculator.Result.value += '8'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="nine" Value="9" OnClick="Calculator.Result.value += '9'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="plus" Value="+" OnClick="checkValidity()"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="minus" Value="-" OnClick="Calculator.Result.value += '-'"&gt;&lt;/td&gt;
              &lt;/tr&gt;      
              &lt;tr&gt;
                 &lt;td&gt;&lt;Input type="button" Name="equals" Value="=" OnClick="Calculator.Result.value = eval(Calculator.Result.value)"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="divide" Value="/" OnClick="Calculator.Result.value += '/'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="multiply" Value="*" OnClick="Calculator.Result.value += '*'"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;Input type="button" Name="clear" Value="C" OnClick="Calculator.Result.value = ''"&gt;&lt;/td&gt;
              &lt;/tr&gt;
           &lt;/table&gt;
           &lt;span id="HoursWorkedThisWeek"&gt;&lt;/span&gt;
           &lt;Input type="button" Name="Save" Value="Save" OnClick="Calculator.HoursWorkedThisWeek = Calculator.Result.value"&gt;
           &lt;Input type="button" Name="Submit" Value="Submit"&gt;
        &lt;/form&gt;
     &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>