Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Practical N0 8: Create a web page to implement Form Events Part-II

Key Events:
onkeydown, onkeypress, onkeyup

<html>
<head>
<title>Mouse event Demo</title>
</head>
<script>
function down()
{
document.frm1.b1.value="Key Down!";
}
function up()
{
document.frm1.b1.value="Key Up!";
}
</script>
</head>
<form name="frm1">
<input type="text" name="t1" value="" onkeydown="down()" onkeyup="up()">
<br>
<input type="button" name="b1" value="Press Key">
</form>
</html>

Output:
Form Events:
onblur:

<html>
<head>
<title>onblur Demo</title>
</head>
<script>
function validate()
{
alert("Please Enter Data")
}
</script>
</head>
<form>
Name=<input type="text" name="t1" value="" onblur="validate()">
<br>
Age=<input type="text" name="t2" value="">
</form>
</html>

Output :
onfocus:

<html>
<head>
<title>onblur Demo</title>
</head>
<script>
function validate()
{
alert("Please Enter Data")
}
</script>
</head>
<form>
Name=<input type="text" name="t1" value="" onblur="validate()">
<br>
Age=<input type="text" name="t2" value="">
</form>
</html>

Output:

You might also like