0% found this document useful (0 votes)
16 views6 pages

Lab 2

The document contains HTML code for a registration form with fields for collecting a user's full name, father's name, CNIC number, address, email, password, telephone number, and course selection. The form also includes a purpose text area and submit/reset buttons. JavaScript code is included to validate the form fields on submission.

Uploaded by

Aisha Anwar
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)
16 views6 pages

Lab 2

The document contains HTML code for a registration form with fields for collecting a user's full name, father's name, CNIC number, address, email, password, telephone number, and course selection. The form also includes a purpose text area and submit/reset buttons. JavaScript code is included to validate the form fields on submission.

Uploaded by

Aisha Anwar
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/ 6

CODE:

<html>

<head>

<script>

function ValidateForm()

var fullname = document.forms["RegForm"]["Full Name"];

var fathername = document.forms["RegForm"]["Father's Name"];

var cnic = document.forms["RegForm"]["CNIC No"];

var email = document.forms["RegForm"]["EMail"];

var phone = document.forms["RegForm"]["Telephone"];

var what = document.forms["RegForm"]["Subject"];

var password = document.forms["RegForm"]["Password"];

var address = document.forms["RegForm"]["Address"];

//conditions using operators

if (fullname.value == "")

window.alert("Please enter your full name.");

name.focus();

return false;

if (fathername.value == "")

window.alert("Please enter your father's name.");

name.focus();

return false;

if (cnic.value == "")
{

window.alert("Please enter your CNIC.");

name.focus();

return false;

if (address.value == "")

window.alert("Please enter your address.");

name.focus();

return false;

if (email.value == "")

window.alert("Please enter a valid e-mail address.");

email.focus();

return false;

if (email.value.indexOf("@", 0) < 0)

window.alert("Please enter a valid e-mail address.");

email.focus();

return false;

if (email.value.indexOf(".", 0) < 0)

window.alert("Please enter a valid e-mail address.");

email.focus();

return false;
}

if (phone.value == "")

window.alert("Please enter your telephone number.");

phone.focus();

return false;

if (password.value == "")

window.alert("Please enter your password");

password.focus();

return false;

if (what.selectedIndex < 1)

alert("Please enter your course.");

what.focus();

return false;

return true;

</script>

<style>

ValidateForm {

margin-left: 70px;

font-weight: bold ;

float: left;

clear: left;

width: 100px;
text-align: left;

margin-right: 10px;

font-family:sans-serif,bold, Arial, Helvetica;

font-size:14px;

div {

box-sizing: border-box;

width: 100%;

border: 100px solid black;

float: left;

align-content: center;

align-items: center;}

form {

margin: 0 auto;

width: 600px;

}</style></head>

<body>

<font color = "red">

<h1 style="text-align: center">SIR SYED UNIVERSITY REGISTRATION FORM </h1>

<form name="RegForm" action="/submit.php" onsubmit="return ValidateForm()"

method="post">

<p style="font-family:verdana"><b>Full Name:</b> <input type="text" size=90 name="Full Name">


</p><br>

<p style="font-family:verdana"><b>Father's Name:</b> <input type="text" size=90 name="Father's


Name"> </p><br>

<p style="font-family:verdana"><b>CNIC number:</b> <input type="text" size=90 name="CNIC No">


</p><br>

<p style="font-family:verdana"><b>Address:</b> <input type="text" size=90 name="Address">


</p><br>
<p style="font-family:verdana"><b>E-mail Address:</b> <input type="text" size=90 name="EMail">
</p><br>

<p style="font-family:verdana"><b>Password:</b> <input type="text" size=90 name="Password">


</p><br>

<p style="font-family:verdana"><b>Telephone:</b> <input type="text" size=90 name="Telephone">


</p><br>

<p style="font-family:verdana"><b>SELECT YOUR COURSE</b>

<select type="text" value="" name="Subject">

<option>SOFTWARE ENGINEERING</option>

<option>BBA</option>

<option>CIVIL ENGINEERINGG</option>

<option>B.COM</option>

<option>ELECTRICAL ENGINEERING</option>

<option>MECHANICAL ENGINEERINGG</option>

<option>COMPUTER ENGINEERINGG</option>

</select></p><br><br>

<p style="font-family:verdana"><b>Purpose for Applying here:</b> <textarea cols="90"


name="Comment"> </textarea></p>

<p><input type="submit" value="send" name="Submit">

<input type="reset" value="Reset" name="Reset">

</font>

</p>

</form>

</body>

</html>
OUTPUT:

You might also like