Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
      <h1>User Registration</h1>
      <h2>New Account</h2>
      <form method="post" id="formSignup">
<p>
        <label for="username">Create a username: </label>
  <input type="text" id="username" /> <span id="tooltip1"></span>
        </p>
      <p>
        <label for="password">Create a password: </label>
        <input type="password" id="password" /> <span id="tooltip2"></span>
                </p>
      <p>
        <label for="cpassword">Confirm password: </label>
        <input type="password" id="cpassword" /> <span id="tooltip3"></span>
        </p>
      <p>
        <label for="selectOption">Subscription: </label>
        <select id="selectOption">
          <option value="yearly">Yearly ($160)</option>
          <option value="monthly">Monthly ($15)</option>
        </select> <span id="tooltip4"></span>
      </p>
        <p>
          <input type="checkbox" id="terms" />
        <label for="terms"> Check to agree to terms &amp; conditions</label> <span id="tooltip5"></span>
        </p>
      <p>
        <input type="submit" value="signup" />
        </p>
       
      </form>

              
            
!

CSS

              
                body {
  background-color: #000;
  color: white;
  margin: 0; 
  padding: 0;}

span {
  color: red;
}

#tooltip4 {
  color: green;
}

#note {
  color: #fff;
  background-color: #000;
  opacity: 0.9;
  box-shadow: -3px 3px 6px #000;
  padding: 1em 1em 2em 1em;
  height: 95%;
  width: 95%;
  position: absolute;
  top: 1em;
  left: 0;}

#note .header + div {
  background: rgb(255, 255, 255);
  background: rgba(255, 255, 255, 1);
  position: relative;
  text-align: center;
  top: 1px;
  color: #d7666b;
  padding: 20px;
  margin: 30px;
  border: 1px solid #d7666b;}

#note h2 {
  color: #d7666b;
  padding-top: 20px;
  padding-bottom: 20px;}

#note a {
  text-decoration: none;
  color: #fff;}

#note .header {
  text-align: right;
  background-color: #000;
  border: none;
  padding: 0 0 0 10px;}

.shown {
  visibility: visible;}

.hidden {
  visibility: hidden;}
              
            
!

JS

              
                var msg = '<div class=\"header\"><a id=\"close\" href="#">close X</a></div>';
msg += '<div><h2>System Maintenance</h2>';
msg += 'Our servers are being updated between 3 and 4 a.m. ';
msg += 'During this time, there may be minor disruptions to service.</div>';

var note = document.createElement('div');    
note.setAttribute('id', 'note');           
note.innerHTML = msg;                        
document.body.appendChild(note);           

function dismissNote() {                    
  document.body.removeChild(note);       
}

var close = document.getElementById('close');   
close.addEventListener('click', dismissNote, false);

function checkUsername() {                      
  var username = tooltip.value;
  if (username.length < 8) {
    tooltipMsg.textContent = 'Not long enough, yet...';
  } else {                                  
    tooltipMsg.textContent = '';                   
  }
}

function checkPassword() {                    
  let pass = password.value;
  if (pass.length < 5) {
    passwordMsg.textContent = 'Not long enough, yet...';
  } else {
    passwordMsg.textContent = '';                    
  }
}

function checkCpassword() {                  
  let cpass = cpassword.value;
  let pass = password.value;
  if (cpass.length < 5) {
    cpasswordMsg.textContent = 'Not long enough, yet...';
  } 
  else if(pass != cpass) {
    cpasswordMsg.textContent = 'Passwords do not match...';
  }
  else {                                 
    cpasswordMsg.textContent = '';                     
  }
}

function tipUsername() {                         
  tooltipMsg.innerHTML = 'Username must be at least 8 characters';
}

function tipPassword() {                         
  passwordMsg.innerHTML = 'Password must be at least 5 characters';
}

function tipCpassword() {                       
  cpasswordMsg.innerHTML = 'Password must be at least 5 characters';
}

var tooltip = document.getElementById('username');
var tooltipMsg = document.getElementById('tooltip1');
var password = document.getElementById('password');
var passwordMsg = document.getElementById('tooltip2');
var cpassword = document.getElementById('cpassword');
var cpasswordMsg = document.getElementById('tooltip3');


tooltip.addEventListener('focus', tipUsername, false);
tooltip.addEventListener('blur', checkUsername, false);

password.addEventListener('focus', tipPassword, false);
password.addEventListener('blur', checkPassword, false);

cpassword.addEventListener('focus', tipCpassword, false);
cpassword.addEventListener('blur', checkCpassword, false);


var form, selectSub, subTooltip, terms, termsTooltip; 
form          = document.getElementById('formSignup');      
selectSub = document.getElementById('selectOption');
subTooltip   = document.getElementById('tooltip4');
terms         = document.getElementById('terms');
termsTooltip     = document.getElementById('tooltip5');

function subHint() {                               
  var pack = this.options[this.selectedIndex].value;     
  if (pack === 'monthly') {                          
    subTooltip.innerHTML = 'Save $20 if you subscribe for 1 year!';
  } else {                                        
    subTooltip.innerHTML = 'Wise choice!';          
  }
}

function checkTerms(event) {                           
  if (!terms.checked) {                              
    termsTooltip.innerHTML = 'You must agree to the terms.'; 
    event.preventDefault();                             
  }
}

form.addEventListener('submit', checkTerms, false);
selectSub.addEventListener('change', subHint, false);
              
            
!
999px

Console