Guest User

Untitled

a guest
Aug 30th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title>Exercise 14 | Activity 1</title>
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <style>
  9. body {
  10. padding: 50px;
  11. }
  12.  
  13. table,
  14. td,
  15. tr {
  16. border: none;
  17. }
  18.  
  19. </style>
  20. </head>
  21.  
  22. <body>
  23.  
  24. <h1>DIGITAL CLOCKS</h1>
  25. <p>Create a web page that contains a digital clock at the top right corner, it should be in 24 hrs. Format </p>
  26.  
  27.  
  28. <form id="form1">
  29. <table id="t1">
  30. <tr>
  31. <td>
  32. <label for="usname">Username</label>
  33. </td>
  34. <td>
  35. <input type="text" name="username" id="usname">
  36. </td>
  37. <td id="uerr" class="err">
  38. </td>
  39. </tr>
  40. <tr>
  41. <td>
  42. <label for="pass">Password</label>
  43. </td>
  44. <td>
  45. <input type="Password" name="pass" id="pass">
  46. </td>
  47. <td rowspan="2" id="perr" class="err">
  48.  
  49. </td>
  50. </tr>
  51. <tr>
  52. <td>
  53. <label for="cpass">Confirm Password</label>
  54. </td>
  55. <td>
  56. <input type="Password" name="cpass" id="cpass">
  57. </td>
  58. <td>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td>
  63. <label for="gender">Gender</label>
  64. </td>
  65. <td>
  66. <input type="radio" name="gender" id="male" value="male">Male
  67. <br>
  68. <input type="radio" name="gender" id="female" value="female">Female
  69. </td>
  70. <td id="gerr" class="err">
  71. </td>
  72. </tr>
  73. <tr>
  74. <td>
  75. <label for="dob">Date Of Birth</label>
  76. </td>
  77. <td>
  78. <input type="date" id="dob" name="dob">
  79. </td>
  80. <td id="derr" class="err">
  81. </td>
  82. </tr>
  83. <tr>
  84. <td>
  85. <label for="courses">Courses Completed</label>
  86. </td>
  87. <td>
  88. <input type="checkbox" name="DBMS" id="DBMS" value="DBMS">DBMS
  89. <br>
  90. <input type="checkbox" name="SE" id="SE" value="SoftwareEngineering">Software Engineering
  91. <br>
  92. <input type="checkbox" name="OS" id="OS" value="Operating Systems">Operating Systems
  93. </td>
  94. <td id="cerr" class="err">
  95. </td>
  96. </tr>
  97. <tr>
  98. <td>
  99. <label for="country">Select Country</label>
  100. </td>
  101. <td>
  102. <select id="country">
  103. <option value="none">--</option>
  104. <option value="US">US</option>
  105. <option value="India">India</option>
  106. <option value="UK">UK</option>
  107. </select>
  108. </td>
  109. <td id="crerr" class="err">
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>
  114. </td>
  115. <td>
  116. <button onclick="validate();">Submit</button>
  117. </td>
  118. </tr>
  119. </table>
  120. </form>
  121.  
  122.  
  123. </body>
  124.  
  125.  
  126. <script>
  127.  
  128. function validate() {
  129.  
  130. var username = document.getElementById("usname").value;
  131. if (username == "") {
  132. document.getElementById("uerr").innerHTML = "Username Should not be Empty";
  133. // return false;
  134. }
  135. if (username.length < 8) {
  136. document.getElementById("uerr").innerHTML = "Username Should be Minimum 8 characters";
  137. // return false;
  138. }
  139. var pass = document.getElementById("pass").value;
  140. var cpass = document.getElementById("cpass").value;
  141. if (pass == "") {
  142. document.getElementById("perr").innerHTML = "Password Should not be Empty";
  143. // return false;
  144. }
  145. if (cpass == "") {
  146. document.getElementById("perr").innerHTML = "Confirm Password Should not be Empty";
  147. // return false;
  148. }
  149. if (pass != cpass) {
  150. document.getElementById("perr").innerHTML = "Passwords don't match";
  151. // return false;
  152. }
  153. var male = document.getElementById("male").checked;
  154. var female = document.getElementById("female").checked;
  155. if (male == false && female == false) {
  156. document.getElementById("gerr").innerHTML = "Select Gender";
  157. // return false;
  158. }
  159.  
  160. var dob = new Date();
  161. dob = document.getElementById("dob").value;
  162. if (dob == "") {
  163. document.getElementById("derr").innerHTML = "Select Date of Birth";
  164. // return false;
  165. }
  166.  
  167. var dbms = document.getElementById("DBMS").checked;
  168. var os = document.getElementById("OS").checked;
  169. var se = document.getElementById("SE").checked;
  170. if (dbms == false && os == false && se == false) {
  171. document.getElementById("cerr").innerHTML = "Select Courses";
  172. // return false;
  173. }
  174. var country = document.getElementById("country").selectedIndex;
  175. if (country == 0) {
  176. document.getElementById("crerr").innerHTML = "Select Country";
  177. // return false;
  178. }
  179.  
  180. // return true;
  181. }
  182.  
  183. </script>
  184.  
  185. </html>
Add Comment
Please, Sign In to add comment