Advertisement
Chessbrain94

Untitled

Jun 14th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>WRD Only</title>
  5.    
  6.     <link rel="stylesheet" href="style.css">
  7. </head>
  8. <body>
  9.     <div style="width: 100%; height: 100%; position: absolute">
  10.     <div id="header">
  11.         <div id="navigationBar">
  12.             <button type="">Registration Page</button>
  13.             <a href="Artanis.html"><button type="">Artanis</button></a>
  14.             <button id="dropbtn">Thrall</button>
  15.             <button type="">About Me</button>
  16.         </div>
  17.     </div>
  18.     <div class="left">aa</div>
  19.     <div class="center">
  20.         <form>
  21.             First Name: <input type="text" id="FName"> <br>
  22.             Last Name: <input type="text" id="LName"> <br>
  23.             Email: <input type="text" id="Email"> <br>
  24.         </form>
  25.         <button type="submit" onclick="reset()">Reset</button>
  26.         <button type="submit" onclick="save()">Save</button>
  27.     </div>
  28.     <div class="right">bb</div>    
  29.     <div id="footer">footer</div>
  30.     </div>
  31.     <script src="mainJS.js"></script>
  32. </body>
  33. </html>
  34.  
  35. ----------------------------
  36.  
  37. #header, #footer {
  38.     height: 10%;
  39.     width: 100%;
  40.     background-color: gray;
  41. }
  42. .left, .right {        
  43.     display: inline-block;
  44.     height: 80%;
  45.     width: 10%;
  46.     background-color: yellow;
  47. }
  48. .right {
  49.     float: right;
  50. }
  51. .left{
  52.     float: left;
  53. }
  54. #footer {
  55.     clear: both;
  56. }
  57. .center{
  58.     background-color: beige;
  59.     height: 80%;
  60.     width: 80%;
  61.     display: inline-block;
  62.     position: absolute;
  63. }
  64. body{
  65.     margin: auto;
  66. }
  67. #navigationBar button{
  68.     display:inline-block;
  69.     padding:5px;
  70.     border: 2px solid #000000;
  71.     font-family: Futura, Tahoma, sans-serif;
  72.     color: #ffffff;
  73.     border-radius: 5px 5px;
  74.     background-color: #cc0323;
  75. }
  76. .error{
  77.     border: 1px dashed red;
  78. }
  79.  
  80. ---------------------------------
  81.  
  82. var elements = document.getElementsByTagName("input");
  83. for (var i = 0; i < elements.length; i++) {
  84.        if (elements[i].type != "submit") {
  85.            elements[i].onblur = check;
  86.        }
  87. }
  88.  
  89. function check(el){
  90.     var a = el.target;
  91.     var b = true;
  92.     if (a.value == null) {
  93.         a = el;
  94.     }
  95.     if(a.value==""){
  96.         a.classList.add("error");
  97.         b = false;
  98.     }else{
  99.         a.classList.remove("error");
  100.         b = true;
  101.     }
  102.     return b;
  103. }
  104.  
  105. function reset(){
  106.     for (var i = 0; i < elements.length; i++) {
  107.        if (elements[i].type != "submit") {
  108.            elements[i].value = "";
  109.            elements[i].classList.remove("error");
  110.        }
  111.     }
  112. }
  113.  
  114. function save(){
  115.     var a = true;
  116.     for (var i = 0; i < elements.length; i++) {
  117.         if (elements[i].type != "submit") {
  118.             if (!check(elements[i])) {
  119.                 a = false;
  120.             }
  121.         }
  122.     }
  123.     return a;
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement