Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.02 KB | None | 0 0
  1. <body>
  2. <p id="registration">Registration</p>
  3.  
  4. <script type="text/javascript">
  5.     function register() {
  6.         var client = {
  7.             email: document.getElementById('email').value,
  8.             name: document.getElementById('name').value,
  9.             birthday: document.getElementById('birthday').value,
  10.             card: {
  11.                 number: document.getElementById('cardNumber').value,
  12.                 status: document.getElementById('status').value
  13.             },
  14.             security: {
  15.                 password: document.getElementById('password').value,
  16.                 codeWord: document.getElementById('codeword').value
  17.             }
  18.         };
  19.  
  20.         var jsonClient = JSON.stringify(client);
  21.         var xhr = new XMLHttpRequest();
  22.         xhr.open('POST', 'rs/register/register', true);
  23.         xhr.setRequestHeader('Content-Type', "application/json");
  24.  
  25.         xhr.send(jsonClient);
  26.  
  27.         xhr.onload = function () {
  28.             if (xhr.status == 200) {
  29.                 alert("Success registration!\nNow log in to your account")
  30.                 window.location.replace("index.html");
  31.             } else if (xhr.status == 500) {
  32.                 alert("Wrong data");
  33.             } else {
  34.                 alert("Error: " + xhr.status);
  35.             }
  36.         };
  37.     }
  38.  
  39.     function getCardNumber() {
  40.         var xhr = new XMLHttpRequest();
  41.  
  42.         xhr.open('GET', 'rs/register/cardnumber', true);
  43.         xhr.send();
  44.  
  45.         xhr.onload = function () {
  46.             if (xhr.status == 200) {
  47.                 document.getElementById('cardNumber').value = xhr.response;
  48.             } else {
  49.                 alert("Error: " + xhr.status);
  50.             }
  51.         };
  52.     }
  53. </script>
  54.  
  55.  
  56. <fieldset id="login_form">
  57.     <p>
  58.         <label for="email">Email</label>
  59.         <input type="email" name="email" id="email">
  60.     </p>
  61.     <p>
  62.         <label for="password">Password</label>
  63.         <input type="password" name="password" id="password">
  64.     </p>
  65.     <p>
  66.         <label for="name">Name</label>
  67.         <input type="text" name="name" id="name">
  68.     </p>
  69.     <p>
  70.         <label for="birthday">Birthday</label>
  71.         <input type="date" name="birthday" id="birthday">
  72.     </p>
  73.     <p>
  74.         <label for="codeword">Codeword</label>
  75.         <input type="text" name="Code word" id="codeword">
  76.     </p>
  77.     <p>
  78.         <label for="cardNumber">Card number</label>
  79.         <input type="number" name="cardNumber" id="cardNumber">
  80.         <button type="button" name="Generate" onclick="getCardNumber()">Generate card number</button>
  81.     </p>
  82. <!--TODO: сделать выпадающий список с credit/debit Сделать генератор-->
  83.     <p>
  84.         <label for="cardStatus">Card status</label>
  85.         <input type="text" name="cardStatus" id="cardStatus">
  86.     </p>
  87.  
  88.     <p>
  89.         <label for="cnn">cnn</label>
  90.         <input type="text" name="cnn" id="cnn">
  91.     </p>
  92.  
  93.     <button type="submit" name="Register" onclick="register()">Register</button>
  94.  
  95.  
  96. </fieldset>
  97. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement