clear format

by bvotcode

HTML

<!DOCTYPE html>
<html>
<head>
<style> 
input[type=text] {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  box-sizing: border-box;
  border: none;
  background-color: #3CBC8D;
  color: white;
}
</style>
<script>
function isValid(selector){
    return ($(selector).filter(function() {
        return (this.value.trim() === "");
    }).css("border-color","#FF0000").length === 0);
}
isValid(#fname, #lname);
</script>

</head>
<body>

<h2>Input fields with color</h2>

<form>
  <label for="fname">First Name</label>
  <input type="text" id="fname" name="fname" value="">
  <label for="lname">Last Name</label>
  <input type="text" id="lname" name="lname" value="Doe">
</form>

</body>
</html>