<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript"> function sum() { var txtFirstNo = document.getElementById('txtFirstNo').value; var txtSecondNo = document.getElementById('txtSecondNo').value; var result = parseInt(txtFirstNo) + parseInt(txtSecondNo); if (!isNaN(result)) { document.getElementById('txtResult').value = result; } } </script>