CS101 Assignment 2 Solution Spring 2018
#1

CS101 Assignment 2
Spring 2018

Solution
Code:
<!DOCTYPE html>
<html>
<head>
    <title>Assignment 2</title>
    <script type="text/javascript">
        function showMessage(){
            alert(document.getElementsByName('program')[0].value);
        }
        function CheckForm(){
            var isValid=true;
            var password = document.getElementsByName('password')[0].value;
            var rePassword = document.getElementsByName('repassword')[0].value;
            if(password.length ==0 || rePassword.length==0) {
                isValid=false;
                alert("One of the two password fields is empty");
            } else {
                if(password != rePassword){
                    isValid=false;
                    alert("Password and Match password are not same !!");
                } else {
                    alert("Password and Match password are same !!");
                }
                if(isValid) {
                    alert("Congratulations, you have successfully registered");
                }
            }
        }

    </script>
    <style type="text/css">
        h1{
            text-align: center;
            font-size: 40px;
        }
        form {
            position: relative;
            margin: 30px auto;
            width: 500px;
            border: 3px solid #1eb6ff;
           padding: 5px;
        }
        form:before {
            content: " ";
            position: absolute;
            z-index: -1;
            top: 3px;
            left: 3px;
            right: 3px;
            bottom: 2px;
            border: 5px solid #000;
        }
        table {
           margin: 0 auto;
           z-index: 1;
           width:55%;
           height: 50px;
        }
    </style>
</head>
<body>
    <form name="myinfo" method="post">
        <h1>VU Signup Form</h1>
        <br/>
        <br/>
        <table>
            <tr>
                <td>Name</td>
                <td><input type="text" name="name" value="Ata Ur Rehman" /></td>
            </tr>
            <tr>
                <td>Father Name</td>
                <td><input type="text" name="fname" value="Hussain Ahmed" /></td>
            </tr>
            <tr>
                <td>Gender:</td>
            </tr>
            <tr>
                <td>Male</td>
                <td><input type="radio" name="gender" value="male" checked="checked"></td>
            </tr>
            <tr>
                <td>Female</td>
                <td><input type="radio" name="gender" value="fmale"></td>
            </tr>
            <tr>
                <td>Date of Birth</td>
                <td><input type="text" value="21/10/1991" name="dob"></td>
            </tr>
            <tr>
                <td>Study program</td>
                <td>
                    <select onchange="showMessage();" name="program">
                        <option value="CS">CS</option>
                        <option value="Accounting">Accounting</option>
                        <option value="Zoology" selected="true">Zoology</option>
                        <option value="HRM">HRM</option>
                        <option value="Mathematics">Mathematics</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Comments:</td>
                <td><textarea rows="10" cols="20">Write something about you here…</textarea></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input type="email" name="email" value="abc@gmail.com"/></td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><input type="password" name="password" /></td>
            </tr>
            <tr>
                <td>Confirm Password:</td>
                <td><input type="password" name="repassword"/></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="submit" name="submit" value="Sign Up" onclick="CheckForm();" />
                    <input type="reset" name="reset" value="Reset" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Copy this code in notepad and save as file.html and open the file in browser to see the result. Then change the personal details such as name, date of birth, gender, program etc according to yours and finally submit the code in word file. 

Good luck!
Reply
#2

ohhhh thanks
Reply
#3

(05-28-2018, 08:58 PM)Muhammad Yaseen Wrote:  ohhhh thanks

You're welcome.

Good luck!
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by adsvoo
01-25-2020, 04:59 PM



Users browsing this thread: 1 Guest(s)