isNaN() Function in JavaScript

JavaScriptNaN stands for not a number in JavaScript.  Floats and integers are basically numbers.  IsNaN() function checks whether the value is number or not.  It will return true or false. This function will be helpful in case you want to avoid users from passing any value other than a number.   Example is given below where we are making use of isNaN() function to detect illegal values before addition.

<title>JavaScript Tutorial </title>
<script type="text/javascript">
function getTotal(){

var first = document.getElementById('first') .value;
var second = document.getElementById('second') .value;

	alert("Please Check for First Number.");

	alert("Please Check for Second Number.");

var total  = parseInt(first) + parseInt(second);
document.getElementById('total') .value = total;
<input  type="textbox" id="first" placeholder="Enter First Number" /> <br /><br />
<input  type="textbox" id="second" placeholder="Enter Second Number" /> <br /><br />
<input  type="textbox" id="total" placeholder="Total" /> <br /><br />
<input  type="button" onclick="getTotal()"  value="Get Total"/>