Sie sind auf Seite 1von 1

Q6.

Create a web page using two image files, which switch between one another as the
mouse pointer moves over the images. Use the onMouseOver and onMouseOut event.
Ans.
<html>
<head>
<title>Changing Image</title>
</head>
<body>
<img src="file:/C:\images\url.jpg" onMouseOver="this.src='file:/C:\images\pic.jpg';"
onMouseOut="this.src='file:/C:\images\url.jpg';">
</body>
</html>

Q7. Write a JavaScript code block, which validates a username and password against hard
coded values.
Ans.
<html>
<head>
<title>Form Validation</title>
<script language="javascript">
function validate()
{
if(document.getElementById('uID').value=="myuid" &&
document.getElementById('pswd').value=="Cdac")
document.writeln("Username and Password is Correct")
else
document.writeln("Username and Password is Invalid")
}
</script>
</head>
<body>
<h1>Validation</h1>
<form>
Username: <input type="text" id="uID"><br>
Password: <input type="password" id="pswd"><br>
<input type="button" onclick="validate()" value="Verify!">
</form>
</body>
</html>

Q8.Write a JavaScript code block, which checks the contents entered in a forms Text
element. If the text entered is in the lower case, convert to upper case.

Das könnte Ihnen auch gefallen