Hello,
I am new to Javascript and cannot find anything to help me with this issue. I have a table (4 rows by 7 columns initially) where the user needs to input numbers in col 1 and col 3. The total of these two columns is stored in col 5. My problem is, negative numbers are accepted values but when the negative sign is entered, "NaN" displays in col 5 until the user enters a number. How do I stop this from being seen by the user? I tried many things but none have worked. If you need more info, please let me know.
Thanks, Nissa
I am new to Javascript and cannot find anything to help me with this issue. I have a table (4 rows by 7 columns initially) where the user needs to input numbers in col 1 and col 3. The total of these two columns is stored in col 5. My problem is, negative numbers are accepted values but when the negative sign is entered, "NaN" displays in col 5 until the user enters a number. How do I stop this from being seen by the user? I tried many things but none have worked. If you need more info, please let me know.
Thanks, Nissa
Code:
function ss_keyhandler(evt) {
//for IE
if (evt.srcElement) {
var code = evt.keyCode;
if (code == 13)
evt.srcElement.blur();
if (((code >=48) && (code <=57))) return;
if (code == 45){
//what do I write here?
return;
}
evt.returnValue = false;
}
if(evt.target){
var code = evt.which;
if (code == 13)
evt.target.blur();
if (((code >=48) && (code <=57))) return;
if (code == 45){
//same prob - what do I write here?
return;
}
return false;
}
}