Java Script


JavaScript Tutorial


Admission Enquiry Form


Print a message "you are teenager!!" when age is assigned to a variable is teenage using if statement.

Example:

<html>
<head>
<title>Print a message using if statement</title>
</head>

<body>
<script>
var num;
num=14;

if(num>=13 && num<18)
{
document.write("You are teenager!!");
}
</script>
</body>
</html>


Print a message "you are teenager!!" in if statement using prompt() function.

Example:

<html>
<head>
<title>Print message according to age using if statement</title>
</head>

<body>
<script>
var num;
num=parseInt(prompt("Enter your age"));

if(num>=13 && num<18)
{
document.write("You are teenager!!");
}
</script>
</body>
</html>


Print a message "you are teenager!!" in if statement on Button click using function.

Example:

<html>
<head>
<title>Print message using function in if statement</title>
<script>
function age()
{
var num;
num=parseInt(prompt("Enter your age"));

if(num>=13 && num<18)
{
document.write("You are teenager!!");
}
}

</script>
</head>

<body>
<input type="button" value="click" onClick="age()">
</body>
</html>