There is curly bracket mismatch and secondly it was not parsing correctly so it was not working. Try with below code:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
$("#sub").click(function(){
var a=parseInt($("#txfirstno").val());
var b=parseInt($("#txsecondno").val());
$("#result").val(a+b);
});
$('#txfirstno, #txsecondno').keydown(function (e) {
if (e.shiftKey || e.ctrlKey || e.altKey) {
e.preventDefault();
}
else
{
var key = e.keyCode;
if (!((key == 8) || (key == 46) || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) {
e.preventDefault();
}
}
});
});
</script>
</head>
<body>
<form Name="vontact"id="main">
First NO:<input type="text" id="txfirstno"/>
Second No:<input type="text" id="txsecondno"/>
Answer:<input type="text" id="result"/>
<input type="button" id="sub" value="ok"/>
</form>
</body>
</html>