12/18/24, 8:02 PM Example7.
html
ExamModel\Example7.html
1 <html>
2 <head>
3 <title>My First Page</title>
4 <link rel ="stylesheet" type ="text/css" href = "FileCSS.css">
5 </head>
6 <body>
7 <script>
8 function Newpage()
9 {
10 var username =document.getElementById("username").value;
11 var password =document.getElementById("password").value;
12 if(username == "")
13 {
14 alert("Please enter your username");
15 return;
16 }
17 else if(password=="")
18 {
19 alert("Please enter your password");
20 return;
21 }
22 var page1 = `
23 <html>
24 <head>
25 <title>User Details</title>
26 <link rel ="stylesheet" type ="text/css" href = "FileCSS.css">
27 </head>
28 <body>
29 <h1>User Details</h1>
30 <p>Username : ${username}</p>
31 <p>Password : ${password}</p>
32 </body>
33 </html>
34 `;
35 var newWindow = window.open();
36 newWindow.document.write(page1);
37 newWindow.document.close();
38
39 }
40 function Reset()
41 {
42 document.getElementById("username").value = "";
43 document.getElementById("password").value ="";
44
45 }
46 </script>
47 <h1>User Login Validation</h1>
48 <p>
49 Username: <input type="text" id="username" name="username" placeholder="Enter
your Username"><br>
50 Password : <input type ="password" id = "password" name ="password" placeholder =
"Enter your Password"><br>
localhost:52817/e55d00f3-9708-48c7-8321-019278902fd5/ 1/2
12/18/24, 8:02 PM Example7.html
51 <input type="submit" value="Login" onclick="Newpage()" ><input type = "reset"
value = "Reset" onclick="Reset()" >
52 </p>
53 </body>
54 </html>
localhost:52817/e55d00f3-9708-48c7-8321-019278902fd5/ 2/2