Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.

JavaScript: isNaN Function



isNaN Function :-
Evaluates an argument to determine if it is not a number.

Syntax :-
isNaN(value)
value = The value you want to evaluate.

Description :-
isNaN is a top-level function and is not associated with any object.

On platforms that support NaN, the parseFloat and parseInt functions return NaN when they evaluate a value that is not a number. isNaN returns true if passed NaN, and false otherwise.



Example:

<html>
<head>
<title>isNaN Fnction</title>

<script language="javascript">
function check()
{
var phone=f1.phone.value;
if(isNaN(phone))
alert("Characters are not allowed in the Phone Number");
else
alert("Your Phone Number is Accepted");
}
</script>

</head>
<body>

<form name="f1">
Phone: <input type="text" name="phone" size="20">
<input type="button" value="check" onclick="check()">
</form>

</body>
</html>

7 comments:

  1. its a trash ....even null is accepted as a phone number

    ReplyDelete
  2. They are not just limited to adults patients they also have a tendency to children,
    to put it differently they aid those patients in
    all avenues of life. You got to get hold of the best professional therapist in town who can help you to fine tune and perfect your personality traits and bolster
    your confidence level to new high. A respiratory therapist has one of the most versatile positions
    within the health sector.
    my webpage :: different types of depressions

    ReplyDelete
  3. function check()
    {
    var phone=f1.phone.value;
    if(phone=="" || isNaN(phone))
    alert("Please INput the correct formet Corrent formet is number");
    else
    alert("Your Phone Number is Accepted");
    }


    It will work for both null and Characters

    For Important JavaScript Books you can visit
    Important JavaScript Books

    ReplyDelete
  4. http://dotnettips4all.blogspot.in/2013/10/isnan-function-in-javascript.html

    ReplyDelete

Google