loading...

CS101 Assignment 2 Solution Spring 2017

Suppose a university offers admissions in different disciplines. To facilitate far flung areas students, the administration decided to make an online webpage through which students can get registered online.

  1. You as a web programmer need to design a webpage having an interactive form which will accept necessary bio data of the student.

The sample webpage shuold look like the following screen shot.

  1. Make some restriction or validation checks on all fields which make sure that no field can be left empty while pressing submit button. The  appropriat  message will be  shown in case of empty field as shown in the screen shot .


Note: No marks will be given if student does not mention his/ her name and VU ID at the top of the registration form.

 

Note: Use only Notepad to write html and JavaScript code. If any other tool is used, then zero marks will be awarded.

Solution:

<html>
<!-- CS101 ASSIGNMENT NO. 2-->
<head>
<title>MC1600000</title>
<script> 
function chkfields() {
if (document.form1.fname.value<1)
window.alert("Name field empty! Please fill")

if (document.form1.cnic.value<1)
window.alert("CNIC field empty! Please fill")

if (document.form1.course.value<1)
window.alert("Course field empty! Please fill")

if (document.form1.session.value<1)
window.alert("Session field empty! Please fill")

if (document.form1.email.value<1)
window.alert("Email field empty! Please fill")

if (document.form1.pswd.value<1)
window.alert("Password field empty! Please fill")

if (document.form1.address.value<1)
window.alert("Address field empty! Please fill")

if (document.form1.gender.value<1)
window.alert("No gender selected! Please select ")

if (document.form1.city.value<1)
window.alert("City not selected! Please select")
};
</script>
</head>
<!--Bc1160000-->
<body bgcolor="#C3C3C3">
<h1 align="center">Student Name: ABC</h1>
<h2 align="center">Student Id: Bc1600000</h2>
<h3 align="center">Registration Form</h3>
<form name="form1">
<table border="0" width="512" align="center" bgcolor="#D7D7D7">
<tr>
<td>Name</td>
<td><input type="text" name="fname" id="name"></td>
<td>CNIC</td>
<td><input type="text" name="cnic" id="cnic"></td>
</tr>
<tr>
<td>Course</td>
<td><input type="text" name="course" id="course"></td>
<td>Session</td>
<td><input type="text" name="session" id="session"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="email" name="email" id="email"></td>
<td>Password</td>
<td><input type="password" name="pswd" id="pswd"></td>
</tr>
<tr>
<td>Address</td>
<td colspan="3"><textarea cols="20" id="address"></textarea></td>
</tr>
<tr colspan="2">
<td>Gender</td>
<td colspan="3"><input type="radio" name="gender" id="male" value="Male"> Male 
<input type="radio" name="gender" id="female" value="Female">Female</td>
</tr>
<tr>
<td>City</td>
<td colspan="3">
<select name="city">
<option value="">---Select--- </option>
<option value="faisalabad">Faisalabad</option>
<option value="lahore">Lahore</option>
<option value="islamabad">Islamabad</option>
</select></td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="new_student" value="nstudent"> New Student 
</td>
<td colspan="2"><input type="checkbox" name="con_student" value="constudent"> Continuing Student
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Submit" onClick="chkfields()"></td>
<td colspan="2" align="left"><input type="reset" value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
<!---->
DOWNLOAD SOLUTION HERE
loading...