0% found this document useful (0 votes)
65 views3 pages

QUESTION NUMBER 1:-Write A Program in Java Script Code For Handling Different Events. Source Code

The document contains code for two JavaScript assignments. The first assignment handles different events using event handlers in HTML tags. The second assignment creates a registration form and validates the fields on submit using JavaScript functions. The validation checks that all fields are filled, password length is at least 6 characters, and name length is greater than 4 characters.

Uploaded by

Tasleem Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views3 pages

QUESTION NUMBER 1:-Write A Program in Java Script Code For Handling Different Events. Source Code

The document contains code for two JavaScript assignments. The first assignment handles different events using event handlers in HTML tags. The second assignment creates a registration form and validates the fields on submit using JavaScript functions. The validation checks that all fields are filled, password length is at least 6 characters, and name length is greater than 4 characters.

Uploaded by

Tasleem Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment Number :10 Roll Number:38

QUESTION NUMBER 1:- Write A program in Java Script code for handling
different events.

SOURCE CODE:-
<Html>
<Head>
<Title>Event Handlers</Title>
</Head>
<script>
function inform()
{
alert("You have activated me by clicking the grey button! Note that the event
handler is added within the event that it handles, in this case, the form button event tag");
}
</script>

<form>
<input type="button" name="test" value="Click me" onclick="inform()">
</form>
<Body onload="alert('This page has finished loading!')">
Welcome to my page
<h1 onmouseover="style.color='red'"
onmouseout="style.color='blue'">This is mouse event handlers</h1>

</body>
</Html>
OUTPUT:-

Page Number:-
Assignment Number :10 Roll Number:38
QUESTION NUMBER 2:- Create one form for registration and check all
validation of feilds.

SOURCE CODE:-
<Html>
<Head>
<Title>Asssignment Number 10 Q2</Title>
</Head>
<Body>
<script language="text/JavaScript">
function validate()
{
var Name=document.myform.Name.value;
var Email=document.myform.Email.value;
var Password=document.myform.Password.value;
var zip=document.myform.Zip.value;
var Country=document.myform.Country.value;
if(Name=" "||Email=" "||Password=" "||Zip=" "||Country=" ")
{
alert("Fields Can't be blank");
return false;
}
else if(Password.length<4)
{
alert("Password Must be 6 characters long");
return false;
}
else if(name.length<3)
{
alert("Name must be greter than 4 chracter");
return false;
}
else
{
return true;
}
}
</script>
<form action="#" name="myform" onsubmit="return validate();">
<table border="5" cellpadding="2" cellspacing="2">
<tr align=left>
<td>Name:</td>
<td><input type="textbox" name="Name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="textbox" name="Email"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="Password"></td>
</tr>
<tr>
<td>Zip:</td>
Page Number:-
Assignment Number :10 Roll Number:38
<td><input type="textbox" name="Zip"></td>
</tr>
<tr>
<td>Country:</td>
<td><select name="Country">
<option value="-1">U.S.A</option>
<option value="1">India</option>
<option value="2">U.K</option>
<option value="3">Russia</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="submit"></td>
</tr>
</table>
</form>
</Body>
</html>
OUTPUT:-

Page Number:-

You might also like