<form>
  <label>
    <span>First Name</span>
    <input type="text" pattern=".{3,}" required title="Enter at least 3 characters.">
  </label>
  <button>Submit</button>
</form>
span {
  display: block;
  margin: 0 0 5px 12px;
}

input {
  border: 2px solid #f2f2f2;
  outline: none;
}
input:focus {
  border-color: #d9d9d9;
}
input:valid {
  border-color: #42d142;
}
input:invalid {
  border-color: #ff8e7a;
}
input.empty {
  border-color: #d9d9d9;
}


















body {
  display: flex;
  min-height: 100vh;
  background: #f1f1f1;
  font-family: 'Lato', sans-serif;
  font-size: 150%;
}

form {
  margin: auto;
}

input, button {
  padding: 15px 20px;
  border-radius: 1px;
  border: 2px solid #bdbdbd;
}

button {
  border-color: #616161;
  background: #616161;
  color: #f6f7f8;
  text-transform: uppercase;
  letter-spacing: 2px;
}
$('input:empty, textarea:empty').addClass('empty');

$('input').keyup(function () {
  if ($(this).val().trim() !== '') {
    $(this).removeClass('empty');
  } else {
    $(this).addClass('empty');
  }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js