Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


        <label for="time">Time, HH:MM</label>
        <input type="text" name="time" id="time" />
    <!--  Texts to show if input is valid/invalid  -->
    <span class="valid">Valid Input</span>
    <span class="invalid">Invalid Input </span>


                form {
    width: 50%;
    margin: 0 auto;

input {
    width: 100%;
    padding: 10px;
    font-size: 18px;
    border-radius: 5px;
    border: 1px solid rgb(192, 192, 192);

label {
  font-size: 16px;

span {
  display: none;
  font-size: 16px;

span.valid {
    color: rgb(7, 105, 7);

span.invalid {
    color: red;


                // here's our input field
const timeInput = document.getElementById("time");

// valid/invalid span elements
const validSpan = document.querySelector("span.valid");
const invalidSpan = document.querySelector("span.invalid");

// listen for keyup event on the input field
timeInput.onkeyup = e => {
  // store the value of the input field here
  let val =;
  // if the input field is not empty
  if ( !== ""){
    // if it's a valid time, show the valid span element
    if (isValidTime(val)) { = "block";

      // hide the invalid span if it's already showing = "none";

    } else if (!isValidTime(val)) {
      // if it's an invalid time, show the invalid span element = "block";

      // hide the valid span if it's already showing = "none";
  } else if ( === "") {
    // else if the input field is empty
    // hide all span elements = "none"; = "none";

// function to check if value if a valid time
function isValidTime(value) {
  // define the time regexp
  let rgx = /^\d\d:\d\d$/;
  // perfrom the pattern search and return true/false
  return rgx.test(value);