I have a input element to accept number type. I know javascript takes input as a string. so I am using parseInt() to convert into integer. but it is not working.
My code is:
<tr>
    <td rowspan="6"><br><br><br><br><br>B1<br> Salary/Pension:</td>
    <td>(1) Salary (excluding all allowances, perquisites and profit in lieu of salary</td>
    <td><input type="text" id="sal" value="0" name="sal" placeholder="" class="form-control "></td>
</tr>
<tr>
    <td>(2) Allowances not exempt</td>
    <td><input type="text" id="allowance" value="0" name="allowance" placeholder="" class="form-control "></td>
</tr>
<tr>
    <td>(3)Value of perquisites</td>
    <td><input type="text" id="perquisites" value="0" name="perquisites" placeholder="" class="form-control "></td>
</tr>
<tr>
    <td>(4) Profits in lieu of salary</td>
    <td><input type="text" id="profit" name="profit" value="0" placeholder="" class="form-control"></td>
</tr>
<tr>
    <td>(5)Deduction u/s 16</td>
    <td><input type="text" id="ded16" name="ded16" value="0" placeholder="" class="form-control"></td>
</tr>
<tr>
    <td>(6)Income chargable under the head 'Salaries':</td>
    <td><input type="text" id="inchargesal" value="0" name="inchargesal" placeholder="" class="form-control" readonly></td>
</tr>
//js part is:
  $(document).ready(function() {
    function change() {
        f = a + b + c + d - e;
        alert(f);
        $('#inchargesal').removeAttr('readonly').val(f);
    }
    $('#sal').on('change', function() {
        var a = parseInt(document.getElementsById("sal").value);
        alert("hi");
        change();
    });
    $('#allowance').on('change', function() {
        b = parseInt(document.getElementById("allowance").value)
        change();
    });
    $('#perquisites').on('change', function() {
        c = parseInt(document.getElementsById("perquisites").value);
        change();
    });
    $('#profit').on('change', function() {
        d = parseInt(document.getElementsById("profit").value);
        change();
    });
    $('#ded16').on('change', function() {
        e = parseInt(document.getElementsById("ded16").value);
        change();
    });
});
here to notice is, when I use alert("hi") above the parseInt statement then alert works fine, however when I use it after that, alert("hi") doesn't work.
what's going wrong? please help.
 
     
    
