Professional Documents
Culture Documents
Practical No-8
Practical No-8
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: