Work out the difference between two values and displaying result in a textbox

Work out the difference between two values and displaying result in a textbox

Im trying to work out the difference between two values in a textbox and display the result on a label or textbox as soon as the second number is entered. 

This is what i tried so far. This is in the <script> element

  1. $('#BeginSN').on(function () {
  2.             var diff = Number($("#EndSN").text()) - Number($("#BeginSN").text());
  3.             $('#Form-amount').val(diff);
  4.         });
This is my control
  1. <label>Number of Forms to be allocated:</label>
  2.                 <input id="Form-amount" type="number" />

So the user will enter a Begin Serial Number then a End Serial Number.  As soon as the end serial number is entered i want to display the difference on a label or textbox on the page.  Thanks in advance for the help.