Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3. i) Create a page with JavaScript to do the following. These can all be on one page.
- (a) Prompt the user for their name.
- (b) Use a pop-up box to welcome the user by name.
- (c) Display the current date on the page in the following format: April 30, 2018. Do not display the
- time. Do not"hard code" the date;
- (d) Display the last modified date of the document.
- (e) Put some useful advice, on any subject, in the status line of the browser.
- <!DOCTYPE html>
- <html>
- <head>
- <title>LAB3</title>
- <link rel="stylesheet" href="main.css">
- </head>
- <body>
- <script>
- var name= window.prompt('Enter your name','First name');
- alert('Hey '+ name + '!, Welcome to the page !');
- function func1() {
- var d = new Date(2018,7,27);
- d.getDate();
- document.getElementById("date").innerHTML = d;}
- function func2() {
- var x = document.lastModified;
- document.getElementById("modified").innerHTML = x;}
- </script><br><br>
- <h2>Click the button to display the date.</h2>
- <button onclick="func1()">See Date</button><br>
- <h2 id="date"></h2><br>
- <h2>Click the button to display the date and time this document was last modified.</h2>
- <button onclick="func2()">See last modified date</button><br>
- <h2 id="modified"></h2><br><br>
- <p><h3>Note:<h3> <h4>Please try loin after some time if you find the page unavailabe.<h4></p>
- </body></html>
- ii) Create a User Registration form with First Name, Last name, Address, City, State, Country, Pincode, Username and Password fields for a General login webpage and satisfy the following criteria. Create a validate ( ) function that does the following:
- (a) Checks that the First Name, Last Name, City, Country, Username, and Password1 fields
- are filled out.
- (b) Checks that the Pincodeis exactly 6 numeric’s.
- (c) Checks that the state is exactly two characters.
- (d) Checks that the email is a valid email address.
- • false if email has fewer than 6 characters
- • false if email does not contain an @ symbol
- • false if email does not contain a period (.)
- • true otherwise
- Code:
- <!DOCTYPE html>
- <html>
- <head><title>FORM</title>
- <link rel="icon" href="favicon.ico" type="image/png">
- <style type="text/css">
- body{
- font-family:Times New Roman;}
- * {box-sizing: border-box;}
- .btn {
- background-color: green;
- color: white;
- padding: 10px 20px;
- border: none;
- cursor: pointer;
- margin-top: 15px;
- padding-left: 30px;
- width: 310px;
- height: 42px;
- font-size: 14px;
- box-shadow: 0 0 10px;
- opacity: 0.9; }
- .btn:hover {
- opacity: 1;
- background-color: tomato;
- }
- #form1{
- width: 500px;
- height: 1050px;
- margin: auto;
- padding: 20px 40px;
- background-color: powderblue;
- color: #333333;
- border: 2px solid #C2D6FF;
- border-radius: 10px;
- border-radius: 40px 0 40px 0;
- margin-top: 15px;
- }
- #email{
- background-image: url('envelope.png');
- background-repeat: no-repeat;
- background-position: 6px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px; }
- #fname{
- background-image: url('avatar.png');
- background-repeat: no-repeat;
- background-position: 6px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px; }
- #phone {
- background-image: url('phone-call.png');
- background-repeat: no-repeat;
- background-position: 5px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px;}
- #address{
- background-image: url('1234.png');
- background-repeat: no-repeat;
- background-position: -2px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px; }
- #password{
- background-image: url('key1.png');
- background-repeat: no-repeat;
- background-position: 2px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px;}
- #cpassword{
- background-image: url('key1.png');
- background-repeat: no-repeat;
- background-position: 2px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px;}
- #pcode{
- background-image: url('1234.png');
- background-repeat: no-repeat;
- background-position: -2px;
- border: 1px solid #DADADA;
- margin: 15px;
- padding-left: 35px;
- width: 310px;
- height: 30px;
- font-size: 14px;
- box-shadow: 0 0 10px;}
- label{ margin:10px; }
- #cont{align-content: center;}
- </style></head>
- <body align="center">
- <div id="form1">
- <h3 style="text-align:centre">REGISTRATION FORM</h3>
- <form style="margin:10%" name="form1" action="#" method="POST">
- <script language="Javascript">
- function Validate() {
- var password = document.getElementById("password").value;
- var confirmPassword = document.getElementById("cpassword").value;
- if (password != confirmPassword) {
- alert("Passwords do not match.");
- return false;
- }
- return true; }
- </script>
- <script language="Javascript">
- (function() {
- $('form > input').keyup(function() {
- var empty = false;
- $('form > input').each(function() {
- if ($(this).val() == '') {
- empty = true;}
- });
- if (empty) {
- $('#register').attr('disabled', 'disabled');
- } else {
- $('#register').removeAttr('disabled');
- }
- });
- })()
- </script>
- <div id="cont">
- <label for="Username"><b>Username:</b></label>
- <input id="fname" type="text" name="username" placeholder="username" required>
- <label for="Email-id"><b>Email-Id:</b></label>
- <input id="email" type="text" name="email" placeholder="email" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$">
- <label for="Password"><b>Password:</b></label>
- <input id="password" type="password" name="password" required pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" placeholder="Enter Password">
- <label for="Confirm Password"><b>Confirm Password:</b></label>
- <input id="cpassword" type="password" name="cpassword" required pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" placeholder="Retype Password">
- <label for="Phone No:"><b>Phone No:</b></label>
- <input id="phone" type="text" name="phoneno" placeholder="phonenumber" required pattern="^([0|\+[0-9]{1,5})?([7-9][0-9]{9})$">
- <label for="Address:"><b>Address:</b></label>
- <input id="address" type="text" name="Address" placeholder="Address" required pattern="^(\w*\s*[\#\-\,\/\.\(\)\&]*)+">
- <label for="Pincode"><b>Pincode:</b></label>
- <input id="pcode" type="text" name="pincode" placeholder="pincode" required pattern="^[1-9][0-9]{5}$">
- <div>
- <label>
- <input type="radio" name="radio" required>Female
- <span class="checkmark"></span>
- </label>
- <label>
- <input type="radio" name="radio" required>Male
- <span class="checkmark"></span>
- </label>
- </div>
- <div>
- <textarea name="message" rows="7" cols="30" placeholder="Write your comments here." required></textarea>
- </div>
- </div>
- <button type="submit" class="btn" onclick="return Validate()" onclick="this.disable=true;" >Register</button>
- <button type="reset" class="btn">Reset</button>
- </form> </div>
- </body></html>
Add Comment
Please, Sign In to add comment