JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' id="TWidth" value="4-1/2" onKeyUp="valid_Dimensions_Width(this);" />
<div id="TWidthError" class="error"></div>
CSS
.error { color: red }
JavaScript
function valid_Dimensions_Width(fieldObj) {
// regular expression
var error = ""
var rgexp = /^([0-9]+|[0-9]+-[0-9]+\/[0-9]+|[0-9]+\/[0-9]+)$/;
var input = fieldObj.value;
if (!input.match(rgexp)) error = "The width field format is incorrect!";
document.getElementById("TWidthError").innerHTML = error;
}