JSFiddle - React, Tailwind, and code Playground
HTML
{% for parameter in apparamlist %}
{% if parameter.parameterId in probe.parameterliste|keys %}
{% if probe.parameterliste[parameter.parameterId].ulockstatus ==2 %}
<td style='background-color:red;text-align:center;' title="{{probe.parameterliste[parameter.parameterId].comentario}}"><input class="resultfield" size='8' type='text' value="{{probe.parameterliste[parameter.parameterId].resultado}}" name={{parameter.parameterId}} id="{{probe.probeId}}"/></td>
{% else %}
<td style='text-align:center;'><input class="resultfield" size='8' type='text' value="{{probe.parameterliste[parameter.parameterId].resultado}}" name={{parameter.parameterId}} id="{{probe.probeId}}" /></td>
{% endif %}
{% else %}
<td> </td>
{% endif %}
{% endfor %}
CSS
input.input-error {
color: #ff0000;
border: 1px solid #ff0000;
box-shadow: 0 0 5px #ff0000;
}
JavaScript
window.onload = function () {
var textbox = document.getElementById("{{probe.probeId}}");
for (param in allparamArray)
{
var maxVal = param.ValorMaximo;
}
addEvent(textbox, "keyup", function () {
var thisVal = +this.value;
this.className = this.className.replace(" input-error ", "");
if (isNaN(thisVal) || thisVal > maxVal) {
this.className += " input-error ";
// Invalid input
}
});
};
function addEvent(element, event, callback) {
if (element.addEventListener) {
element.addEventListener(event, callback, false);
} else if (element.attachEvent) {
element.attachEvent("on" + event, callback);
} else {
element["on" + event] = callback;
}
}