JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr>
<td>Row 1</td>
<td><div id="div1"> <input type="text" name="one"/> </div></td>
</tr>
<tr>
<td>Row 1</td>
<td><div id="div2"> <input type="text" name="two" /> </div></td>
</tr>
</table>
<input type="submit" onclick="validateInput()" value="submit" />
JavaScript
var tblElement = document.getElementById('mytable'),
txtElements = tblElement.getElementsByTagName('input');
for(var i=0; i<txtElements.length; i++){
if(!isValid) break;
var item = txtElements[i],
val = item.value;
alert (val);
console.log(item);
// do your validation here
isValid = (val >= 100);
}
if(isValid){
// do something or do nothing, form will be submitted
alert('All good, form will be submitted');
} else {
// show some kind of error to the user
alert('Some values are lower than 100');
}
return isValid;
}
return isValid;
}