I'm working on a sudoku project and am stumped by validation, the table code is the same throughout so I'll post a small block of code unless more is needed. What I'm trying to do is get the value from each table data cell in my sudoku, and onkeyup, allow only numbers between 1-9. All other characters will produce an error. Here's what I have so far, my javascript function doesnt seem to be getting any values, and I cant figure out why.
<table class="spuzzle">
<thead>
<tr><th></th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
</tr>
</thead>
<tbody>
<tr>
<th>A</th>
<td class ="greenBox" rowspan="3" colspan="3">
<table class="subTable">
<tr>
<td contenteditable="true" onkeyup="myFunction()"></td>
<td contenteditable="true" onkeyup="myFunction()"></td>
<td>4</td>
</tr>
<tr>
<td contenteditable="true" onkeyup="myFunction()"></td>
<td contenteditable="true" onkeyup="myFunction()"></td>
<td contenteditable="true" onkeyup="myFunction()"></td>
</tr>
<tr>
<td>3</td>
<td>5</td>
<td contenteditable="true" onkeyup="myFunction()"></td>
</tr>
</table>
</td>
function myFunction()
{
var num = document.getElementsByClassName("subTable").value;
var num = parseInt(num, 10);
alert(num);
if(num < 1 || num > 9){
document.getElementsByClassName("subTable").value = "";
alert("Please Enter a Number Between 1 and 9.");
}
}