I have already got this working, but I know there must be a more succinct way of doing it.
Using onBlur on a text field in the html page, it calls a method which replaces the value of the string if the value is empty or NaN.
JS:
function checkStr(str) {
return str.value = "0";
}
HTML:
onblur="if(this.value=='' || isNaN(this.value)){this.value=checkStr(this.value)};"
So this does work, but seems exhaustive. Using:
function checkStr(str) {
if (str.value == "" || isNaN(str.value)) {
return str.value = "0";
}
}
In the JS file, and:
onblur="checkStr(this.value);"
In the HTML doesn't work.
Any ideas?
onblur="checkStr();"in the HTML... did you pass the value? Like this:onblur="checkStr(this.value);"