Comment #1 on issue 36974 by js...@chromium.org: mtgprofessor.com :
mortgage calculator does not work (verification failure)
http://code.google.com/p/chromium/issues/detail?id=36974
1. Go to
http://www.mtgprofessor.com/Calculators/Calculator2a.html
(or any other mtg calculator at the site)
2. fill out the form: say mtg amount = 100000, loan term=360, interest
rate=4.25,
extra monthly payment = 500, start month = 1
3. press 'display loan schedule' or 'display extra pmnt benefit' button
Expected: the result page shows up
Actual: the alert box shows up saying that 'AmtOfChg1 is less than or
greater than'
Analysis:
http://www.mtgprofessor.com/mpcalculators/ExtraPaymentsCalculator/ExtraPayments1.asp
has the following:
<form ACTION="ExtraPayments1Vars.asp" METHOD="POST" onSubmit="
this.LoanAmt.min = 0;
this.LoanAmt.max = 5000000;
this.intrate.min = 0;
this.intrate.max = 30;
this.loanterm.min = 1;
this.loanterm.max = 480;
return verify(this);">
... snip ....
<input NAME="LoanAmt" SIZE="10" MAXLENGTH="10" value="" align="middle"
tabindex="1" > </font></td>
<input NAME="loanterm" SIZE="10" MAXLENGTH="10" value="" tabindex="3" >
</font></td>
...
<input NAME="AmtOfChg1" SIZE="10" MAXLENGTH="10" value="" tabindex = "6">
</td>
....
function verify(f) has the following:
// where f is the form shown above.
for(var i = 0; i < f.length; i++) {
var e = f.elements[i];
if ((e.type == "text") && (e.value > "")){
// Now check for fields that are supposed to be numeric.
if (e.numeric || (e.min != null) || (e.max != null)) {
var v = parseFloat(e.value);
if (isNaN(v) ||
((e.min != null) && (v < e.min)) ||
((e.max != null) && (v > e.max))) {
errors += "- " + e.name + " must be a number";
if (e.min != null)
errors += " that is equal to or greater than " +
e.min;
if (e.max != null && e.min != null)
errors += " and less than " + e.max;
else if (e.max != null)
errors += " that is less than " + e.max;
errors += ".\n";
}
}
}
For loanAmt, intrate, loanTerm, min and max are defined, but for the rest
of input elements, min/max are not defined. However, in Chrome (I haven't
checked Safari, yet), e.min and e.max (|e| corresponds to an element
inside 'form' element) are not null nor undefined. Instead, they're empty
string. So, the condition in 4 if-statements are true and |v| is compared
against an empty string.
I don't know yet what's the standard behavior (empty string vs null vs
undefined).
Apparently, Firefox and IE use null while Chrome uses an empty string.
I'll upload a reduced test case.
Comment #3 on issue 36974 by js...@chromium.org: mtgprofessor.com :
mortgage calculator does not work (verification failure)
http://code.google.com/p/chromium/issues/detail?id=36974
(No comment was entered for this change.)