Menus

Jun 8, 2016

Javascript program to check if entered number is valid or not.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Number Valid Form</title>
<script type="text/javascript">
function validNumber(thisform)
        {
        var num=thisform.num.value;
        if(num==null || num =="")
                {
                alert("Enter the Number");
                thisform.num.focus();
                return false;
                }
        if(isNaN(num))
                {
                alert("It's not a Valid Number");
                thisform.num.focus();
                return false;
                }
        return true;
        }

</script>
<body>
<form action="number_valid.html" onsubmit="return validNumber(this)" method="post">
        Enter Number : <input type="text" name="num"/> <br />
        <input type="submit" value="submit"/>
</form>

</body>

</html>

No comments:

Post a Comment

Contact Form

Name

Email *

Message *