JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>TEST</title>
</head>
<body>
<form id="DoesTheRealFormHaveAnId">
<table width="100%">
<tbody>
<tr>
<td align="left" width="150">Destination: </td>
<td><input id="dest" name="dest" value="" size="5" type="text"></td>
</tr>
<tr>
<td align="left" width="150">Priority: </td>
<td><input id="prio" name="prio" type="text" value="285"></td>
</tr>
<tr>
<td align="left" width="150">Success: </td>
<td><input id="succ" name="succ" type="text" value="6"></td>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Submit">
</td>
</tr>
</tbody>
</table>
<br/>
<table border="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="user">
<a href="#" class="nav" title="Logout John">Logout</a>
(User: Steve)
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
CSS
body {margin-top:20px;}
table {background-color:#ccc;padding:20px 10px;}
JavaScript
//--- Make sure this list of names is all uppercase.
var usersWhoCanSetPriority = ['JOHN', 'LUKE', 'JEFF', 'MAX', 'ANDY'];
var excludedDestinations = ['12', '22'];
var bDisablePrio = true;
var tdNodes = document.getElementsByTagName ("TD");
for (var J = tdNodes.length - 1; J >= 0; --J) {
var tdNode = tdNodes[J];
if (tdNode.className == "user") {
var userName = tdNode.textContent.replace (
/^(?:.|\n|\r)+\(User:\s+([^)]+)\)(?:.|\n|\r)+$/i, "$1"
).toUpperCase ();
if (usersWhoCanSetPriority.indexOf (userName) > -1) {
bDisablePrio = false;
}
}
}
if (bDisablePrio) {
var oldInput = document.getElementsByName ("prio");
if (oldInput && oldInput.length) {
oldInput[0].setAttribute ("disabled", "disabled");
}
var destInput = document.getElementsByName ("dest");
if (destInput && destInput.length) {
destInput[0].addEventListener (
"change",
function (zEvent) {
bCheckdestinationValue (destInput[0]);
},
false
);
//--- Extra added to try and get FF2 to behave as later versions do.
destInput[0].addEventListener (
"keydown",
function (zEvent) {
if (zEvent.keyCode == 13) {
if ( bCheckdestinationValue (destInput[0]) ) {
console.log ("Enter blocked.");
zEvent.preventDefault ();
zEvent.stopPropagation ();
return false;
}
}
},
true
);
destInput[0].form.addEventListener (
"submit",
function (zEvent) {
var destValue = destInput[0].value;
if ( destValue === ''
|| excludedDestinations.indexOf (destInput[0].value) > -1
) {
...