daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Sep 20th, 2016 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <form name="registration" novalidate>
  3. Username:<input type="text" name="username" id="username" required><p class="error"></p></br>
  4. Password:<input type="password" name="password1" id="password1" required></br>
  5. Confirm Password:<input type="password" name="password2" id="password2" required></br>
  6. Email:<input type="email" name="email" id="email" required></br>
  7.  
  8. <input type="submit">
  9.  
  10.  
  11. <script>
  12.  
  13.  (function() {
  14.     var form = document.getElementById('registration');
  15.     var username = document.getElementById('username');
  16.     var password1 = document.getElementById('password1');
  17.     var password2 = document.getElementById('password2');
  18.     var email = document.getElementById('email');
  19.    
  20.    var CheckUsernameValue function() {
  21.         if (username.value != "") {
  22.             username.setCustomValidity('Please enter a Username!');
  23.             updateErrorMessage();
  24.         } else {
  25.             username.setCustomValidity('');
  26.         }        
  27.     };
  28.     var updateErrorMessage = function() {
  29.         form.getElementsByClassName('error')[0].innerHTML = username.validationMessage;
  30.     };
  31.    
  32.    form.addEventListener('submit', function(event) {
  33.         if (form.classList) form.classList.add('submitted');
  34.         CheckUsernameValue();
  35.         if (!this.CheckUsernameValue()) {
  36.             event.preventDefault();
  37.             updateErrorMessage();
  38.             username.focus();  
  39.         }
  40.     }, false);
  41.    
  42.  });
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top