JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" size="20" id="rbgTextbox" onkeypress="CheckKeyPress(event);" />
JavaScript
function CheckKeyPress(keyPressEvent) {
var element = document.getElementById('rbgTextbox');
if (ValidateRGBTextboxInput(keyPressEvent))
ChangeBackgroundColor(element.value);
else
return false;
}
function ValidateRGBTextboxInput(e) {
return document.getElementById('rbgTextbox').value.length < 6 &&
(e.which >= 48 &&
e.which <= 57 ||
e.which >= 65 &&
e.which <= 70 ||
e.which >= 97 &&
e.which <= 102);
}
function ChangeBackgroundColor(color) {
alert("Color is: " + color);
//ById('gameArea').style.backgroundColor = '#'+color;
//ById('nextPiece').style.backgroundColor = '#'+color;
}