Guest User

Untitled

a guest
Dec 27th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>Creating a Login form with validations </title>
  7. <link href="css/formstyle.css" rel="stylesheet">
  8. <style id="jsbin-css">
  9. body{
  10. background-color:#eee;
  11. }
  12. h1{
  13. color:white;
  14. text-align:center;
  15. line-height:100px;
  16. width:100%;
  17. height:100px;
  18. background-color:gray;
  19. }
  20. h5{
  21. text-align:center;
  22. font-size:1.3em;
  23. font-family:arial;
  24. }
  25. input[type=text],input[type=password]{
  26. width: 100%;
  27. height: 40px;
  28. padding: 5px;
  29. margin-bottom: 25px;
  30. margin-top: 5px;
  31. border: 2px solid #ccc;
  32. color: #4f4f4f;
  33. font-size: 16px;
  34. border-radius: 5px;
  35. }
  36.  
  37. label{
  38. color: #464646;
  39. text-shadow: 0 1px 0 #fff;
  40. font-size: 16px;
  41. font-weight: bold;
  42. }
  43.  
  44. input[type=button]{
  45. font-size: 16px;
  46. background: linear-gradient(#ffbc00 5%, #ffdd7f 100%);
  47. border: 1px solid #e5a900;
  48. color: #4E4D4B;
  49. font-weight: bold;
  50. cursor: pointer;
  51. width: 30%;
  52. border-radius: 5px;
  53. margin:10px 120px;
  54. padding: 10px 0;
  55. outline:none;
  56. }
  57. input[type=button]:hover{
  58. background: linear-gradient(#ffdd7f 5%, #ffbc00 100%);
  59. }
  60.  
  61.  
  62. #box{
  63. background-color:lightgray;
  64. border:1px solid green;
  65. width:350px;
  66. height:500px;
  67. padding:5px 20px;
  68. margin:auto;
  69. }
  70. </style>
  71. </head>
  72. <body>
  73. <div class="container-fluid">
  74.  
  75. <div class="row bg-secondary">
  76. <div class="col-md-12"><h1>Login Page</h1></div>
  77. </div>
  78. <br><br><br>
  79.  
  80. <div class="row">
  81. <div class="col-md-4"></div>
  82. <div class="col-md-4" id="box">
  83. <h5>Please Log In Here !</h5>
  84.  
  85.  
  86.  
  87. <form id="form" name="myform" autocomplete="on">
  88. <label>Email Id :</label></br>
  89. <input type="text" name="email" id="email"/></br>
  90.  
  91. <label>Password :</label></br>
  92. <input type="password" name="password" id="password"/></br>
  93.  
  94. <p align="center">Don't have an account,Please click on <a href="register.html">register</a></p>
  95. <input type="button" value="Log In" id="submit" onclick="validate()"/>
  96. </form>
  97. <span><b class="note">Note : </b>For this demo use following email id and password. <br/><b class="valid">Email Id : user@gmail.com<br/>Password : 123456</b></span>
  98.  
  99.  
  100. </div>
  101. <div class="col-md-4"></div>
  102. </div>
  103. </div>
  104.  
  105. <script src="js/indexscript.js" type="text/javascript"></script>
  106.  
  107. <script id="jsbin-javascript">
  108. var attempt = 3; //Variable to count number of attempts
  109.  
  110. //Below function Executes on click of login button
  111. function validate(){
  112. var email = document.getElementById("email").value;
  113. var password = document.getElementById("password").value;
  114.  
  115. if ( email == "user@gmail.com" && password == "123456"){
  116. alert ("Login successfully");
  117. window.location = "curd.html"; //redirecting to other page
  118. return false;
  119. }
  120. else{
  121. attempt --;//Decrementing by one
  122. alert("You have left "+attempt+" attempt;");
  123.  
  124. //Disabling fields after 3 attempts
  125. if( attempt == 0){
  126. document.getElementById("email").disabled = true;
  127. document.getElementById("password").disabled = true;
  128. document.getElementById("submit").disabled = true;
  129. return false;
  130. }
  131. }
  132. }
  133. </script>
  134.  
  135. <script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
  136. <html>
  137. <head>
  138. <meta charset="utf-8">
  139. <meta name="viewport" content="width=device-width">
  140. <title>Creating a Login form with validations </title>
  141. <link href="css/formstyle.css" rel="stylesheet">
  142. </head>
  143. <body>
  144. <div class="container-fluid">
  145.  
  146. <div class="row bg-secondary">
  147. <div class="col-md-12"><h1>Login Page</h1></div>
  148. </div>
  149. <br><br><br>
  150.  
  151. <div class="row">
  152. <div class="col-md-4"></div>
  153. <div class="col-md-4" id="box">
  154. <h5>Please Log In Here !</h5>
  155.  
  156.  
  157.  
  158. <form id="form" name="myform" autocomplete="on">
  159. <label>Email Id :</label></br>
  160. <input type="text" name="email" id="email"/></br>
  161.  
  162. <label>Password :</label></br>
  163. <input type="password" name="password" id="password"/></br>
  164.  
  165. <p align="center">Don't have an account,Please click on <a href="register.html">register</a></p>
  166. <input type="button" value="Log In" id="submit" onclick="validate()"/>
  167. </form>
  168. <span><b class="note">Note : </b>For this demo use following email id and password. <br/><b class="valid">Email Id : user@gmail.com<br/>Password : 123456</b></span>
  169.  
  170.  
  171. </div>
  172. <div class="col-md-4"></div>
  173. </div>
  174. </div>
  175.  
  176. <script src="js/indexscript.js" type="text/javascript"><\/script>
  177.  
  178. </body>
  179. </html>
  180. </script>
  181.  
  182. <script id="jsbin-source-css" type="text/css">body{
  183. background-color:#eee;
  184. }
  185. h1{
  186. color:white;
  187. text-align:center;
  188. line-height:100px;
  189. width:100%;
  190. height:100px;
  191. background-color:gray;
  192. }
  193. h5{
  194. text-align:center;
  195. font-size:1.3em;
  196. font-family:arial;
  197. }
  198. input[type=text],input[type=password]{
  199. width: 100%;
  200. height: 40px;
  201. padding: 5px;
  202. margin-bottom: 25px;
  203. margin-top: 5px;
  204. border: 2px solid #ccc;
  205. color: #4f4f4f;
  206. font-size: 16px;
  207. border-radius: 5px;
  208. }
  209.  
  210. label{
  211. color: #464646;
  212. text-shadow: 0 1px 0 #fff;
  213. font-size: 16px;
  214. font-weight: bold;
  215. }
  216.  
  217. input[type=button]{
  218. font-size: 16px;
  219. background: linear-gradient(#ffbc00 5%, #ffdd7f 100%);
  220. border: 1px solid #e5a900;
  221. color: #4E4D4B;
  222. font-weight: bold;
  223. cursor: pointer;
  224. width: 30%;
  225. border-radius: 5px;
  226. margin:10px 120px;
  227. padding: 10px 0;
  228. outline:none;
  229. }
  230. input[type=button]:hover{
  231. background: linear-gradient(#ffdd7f 5%, #ffbc00 100%);
  232. }
  233.  
  234.  
  235. #box{
  236. background-color:lightgray;
  237. border:1px solid green;
  238. width:350px;
  239. height:500px;
  240. padding:5px 20px;
  241. margin:auto;
  242. }
  243. </script>
  244.  
  245. <script id="jsbin-source-javascript" type="text/javascript"> var attempt = 3; //Variable to count number of attempts
  246.  
  247. //Below function Executes on click of login button
  248. function validate(){
  249. var email = document.getElementById("email").value;
  250. var password = document.getElementById("password").value;
  251.  
  252. if ( email == "user@gmail.com" && password == "123456"){
  253. alert ("Login successfully");
  254. window.location = "curd.html"; //redirecting to other page
  255. return false;
  256. }
  257. else{
  258. attempt --;//Decrementing by one
  259. alert("You have left "+attempt+" attempt;");
  260.  
  261. //Disabling fields after 3 attempts
  262. if( attempt == 0){
  263. document.getElementById("email").disabled = true;
  264. document.getElementById("password").disabled = true;
  265. document.getElementById("submit").disabled = true;
  266. return false;
  267. }
  268. }
  269. }
  270. </script></body>
  271. </html>
Add Comment
Please, Sign In to add comment