Need help on coding for this textbox

I have a function below where every time a question is submitted, it will add a new row in the table with a textbox which allows numbers entry only. My question is that I don’t know how to code these features in this function:

1: I want the text box to be between 0 and 100, so if text box contains a number which is above 100, it will automatically change the number to the maximum number which is 100.

Does any one know how to code this in my function below in javascript:

function insertQuestion(form) 
         var row = document.createElement("tr");
         var cell, input;
    cell = document.createElement("td");
         cell.className = "weight";
         input = document.createElement("input"); = "weight_" + qnum;
         input.onkeypress = "return isNumberKey(event)";

I don’t think you actually wrote the code you posted because if you did, then you would know that the code you are asking for needs to go into your onkeypress event handler and not the function you posted.