cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
                <form>
  <h1>New User Signup</h1>
  <label for="pass" class="pass-label">Password - <span class="tip-icon"></span> 
    <ul class="tip">
      <li>The password length must be greater than or equal to 7</li>
      <li>The password must contain one or more uppercase characters</li>
      <li>The password must contain one or more lowercase characters</li>
      <li>The password must contain one or more numeric values</li>
      <li>The password must contain one or more special characters</li>
    </ul>
    <input id="pass" type="password" required pattern="(?=^.{7,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"></label><label for="pass-confirm" class="pass-label">Confirm Password
    <input id="pass-confirm" type="password" required></label>
    
    <div>
      <input type="submit" class="submit"/>
    </div>
   
  </form>

            
          
!
            
              $success: #007621;
$required: #B00000;
$error: #DC0809;
$black: #000000;
$white: #fff;
$grey: #aaaaaa;

html, body{
  margin:0;
  height:100%;
  font-family: Helvetica, Arial, sans-serif;
}

body {
  background: rgb(244,239,241);
  background: radial-gradient(ellipse at center,  rgba(244,239,241,1) 0%,rgba(80,90,100,1) 100%);
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4eff1', endColorstr='#dfd2f7',GradientType=1 );
}

form {
  position: relative;
  padding: 20px;
  height: 100%;
  width: 60%;
  margin: auto;
}

label {
  display: inline-block;
}

input:not([type=submit]) {
  margin-bottom:20px;
  border: 1px solid $grey;
  padding: 5px;
  width:98%;  
  transition:border-color 500ms;
  
  /* Mark required fields */
  &:required {
    border-right: 2px solid $required;
  }
  /*
  :required:valid will change the red required mark to green when requirement is met.
  good for input patterns:
  https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-pattern
*/
  &:valid {
    border-right: 2px solid $success;
  }
  &.error {
    border: 1px solid $error;
  }
  
  &:focus {
    outline: 0 none;
  }  
}

.pass-label {
  width: 47%;
  margin-right: 5%;
  &:nth-child(2n+1){
    margin-right: 0;
  }
}

input[type=password] {
  width:96%;
}

.tip-icon {
  font-size:.75em;
  color: $white;
  line-height: 1em;
  margin-bottom: 10px;
  &:before{
    content: '?';
    position: absolute;
    background: #333;
    padding: 3px 3px 3px 1px;
    border-radius: 3px;
    width: 12px;
    height: 12px;
    text-align: center;
  }
  &:hover ~ .tip {
    height:140px;
  }
  ~ .tip {
    height: 0;
    overflow:hidden;
    display:block;
    width:90%;
    position: absolute;
    background: lighten($grey, 20%);
    transition: height 500ms ease-in-out;  
    margin: 0;
    li {
      padding: 5px;
    }
  }
}

em {
  font-size: small;
  color: $grey;
}

.submit{
  clear:left;
  float:right;
}

            
          
!
            
              // Registration passwords should match
var password = document.getElementById('pass'),
  passwordConfirm = document.getElementById('pass-confirm'),
  errorInputs = document.getElementsByClassName('has-error'),
  registrationUtils = {};

/**
 * Save the user from having to find out their
 * passwords dont match after save by checking now
 * and updating browser validity message with our own.
 * @return {bool}
 */
registrationUtils.confirmMatch = function() {
  if (password.value !== passwordConfirm.value) {
    passwordConfirm.setCustomValidity('Passwords do not match');
  } else {
    passwordConfirm.setCustomValidity('');
  }
  return true;
};

/**
 * Check that the password meets our security policy
 * @return {bool}
 */
registrationUtils.validatePasswordPolicy = function() {

  var policy = new RegExp(password.pattern);

  if (!policy.test(password.value)) {
    password.setCustomValidity('Password does not meet requirements (try "aBc+123")');
  } else {
    password.setCustomValidity('');
  }

  return password.validity.valid;
};

/**
 * Remove error styling from fields onfocus
 * @param  {object} input DOM element with error
 * @return {bool}
 */
registrationUtils.removeErrorClass = function(input) {
  input.className = '';
  return true;
};

/**
 * Bind util methods to objects in DOM
 * @type {object}
 */
password.onchange = registrationUtils.validatePasswordPolicy;
passwordConfirm.onkeyup = registrationUtils.confirmMatch;

// loop through all the inputs with errors
for (var i = errorInputs.length - 1; i >= 0; i--) {
  errorInputs[i].onfocus = registrationUtils.removeErrorClass.bind(null, errorInputs[i]);
}
            
          
!
999px
Loading ..................

Console