Frank,
Here's what you can start with...
<input id='box1' type='text' onchange='validateValue(this)'
onkeypress='return checkKey(this, event)' ... />
JavaScript initialization of the text box (for last validated value):
var box1 = getElementById('box1');
box1.validValue = -1; //Initial value
Javascript functions:
function checkKey(sender, e)
{
// Use this if you want to validate each key-press
// Return true if you accept the character typed, false if you
don't want to be accepted
return true;
}
function validateValue(tb)
{
var value = tb.value;
var setVal = tb.validValue; // The last stored valid value
try
{
var intval = int.Parse(value);
if(intval >= -170 && intval <= 170)
{
setVal = intval;
}
} catch { }
tb.validValue = setVal; // This is for internal use
tb.value = setVal; // This is what keeps changing as
user types
}
For exact and advanved javascript, you may like to go to flashy places
like
www.dynamicdrive.com etc.