JSFiddle - React, Tailwind, and code Playground
by Bill Gilmore
HTML
<input type="tel" id="textBox"/>
<input type="button" id="submit" value="Go"/>
JavaScript
$(document).ready(function() {
$("#submit").click(function(){
var textBoxValue = $("#textBox").val();
if (textBoxValue.length == 0) {
alert("you didnt enter a value");
} else if (textBoxValue.length < 6) {
alert("you only entered " + textBoxValue.length + " chacters, a HEX code needs 6");
} else if (textBoxValue.length == 6) {
var newHEXcode = "#" + textBoxValue;
alert("new HEX code = " + newHEXcode)
// use newHEXcode variable to apply styles here
} else {
alert("you only entered " + textBoxValue.length + " chacters, thats too many, a HEX code needs 6");
}
});
});