bloke
08-26-2003, 09:15 AM
Hi
Can one of you clever people tell me what is wrong with this:
<SCRIPT LANGUAGE=javascript>
var total = 0;
function addVal(obj)
{
if (isNan(obj))
{
alert("Please enter only numerical characters")
obj.focus()
return false
}
else
{
total = parseFloat(total) + parseFloat(obj.value);
document.frm.totalvalue.value = Math.abs(total);
}
}
</script>
The else part of it works fine alone and is activated with onBlur it's just that if someone tabs out of an empty field, the totalvalue field becomes NaN therefore I only want to activate the sum and return if there is a value entered into the field.
I get an 'object expected' error and I'm just about ready to throw in the towel!
Any help much appreciated.
Cheers
Can one of you clever people tell me what is wrong with this:
<SCRIPT LANGUAGE=javascript>
var total = 0;
function addVal(obj)
{
if (isNan(obj))
{
alert("Please enter only numerical characters")
obj.focus()
return false
}
else
{
total = parseFloat(total) + parseFloat(obj.value);
document.frm.totalvalue.value = Math.abs(total);
}
}
</script>
The else part of it works fine alone and is activated with onBlur it's just that if someone tabs out of an empty field, the totalvalue field becomes NaN therefore I only want to activate the sum and return if there is a value entered into the field.
I get an 'object expected' error and I'm just about ready to throw in the towel!
Any help much appreciated.
Cheers