I Fixed the Same Bug in Twenty Calculators
Some of the number boxes on ToolGrit fought the people typing into them. This is what that looked like, how I fixed it once for twenty calculators, and how to check your own site for the same thing.
What ToolGrit Is
ToolGrit is my site of free calculators for the trades: generator sizing, wire sizing, voltage drop, grain bin capacity, trench sloping and a few hundred more. This week the home page counts 384 calculators across 21 trades. Free, no login.
The Report
Someone sent a bug report through my contact form. The pipe footage and available voltage boxes on the cathodic protection calculator would not take the numbers he had. They put in numbers he never typed.
He was right. I tried it. Typing 1500 into pipeline length ended at 500000. Typing 12.5 into available voltage ended at 100.
What Was Going On
The box checked the number on every keystroke instead of when you were done typing.
Here is what that does, one key at a time. The system pressure box on the compressed air calculator has a floor of 50. Type 120. The 1 is below 50, so the box changes it to 50 the moment you press it. The 2 makes it 502. The 0 makes it 5020. You typed 120. The box says 5020.
Other boxes failed in other ways:
- Some would not let you clear them. Backspace, and the old number came right back.
- Some blanked out a typed 0, so 0.5 could not be entered.
- On the weld heat input calculator, the decimal point disappeared, so 22.5 volts could not be typed.
- On the mini-split calculator, the temperature boxes would not take a minus sign. That is a problem in North Dakota.
- On the generator sizing calculator, every keystroke in running watts pushed surge watts up for some loads, and deleting a digit never brought it back down.
Why It Was in Twenty Places
The cathodic calculator was not the only one built this way. Once I knew the pattern, I searched the code of the other calculators for it and kept finding it. The same mistake came in a few shapes, but the cause was always the same: a box that judged the number before you finished it.
The fix went into twenty calculators. Among them: compressed air, wood speeds and feeds, generator sizing, water heater sizing, conduit fill, fire sprinkler hydraulics, weld heat input and lift station runtime.
The Fix
Patching twenty calculators one at a time is how you end up with twenty slightly different bugs. So I wrote one shared number box, plus a sibling for boxes that are allowed to stay empty, and put it in all twenty. It follows four rules:
- While you type, it keeps exactly what you typed. Nothing is checked or corrected mid-number.
- It checks the number when you leave the box, by clicking away or pressing Enter, and only if the number actually changed.
- Limits apply only to what you typed. A value the calculator was already holding stays put when you pass through the box without changing it.
- Afterwards it shows what the calculator kept, not what you hoped it kept.
Rule three came from testing my own first version of the fix. On the lift station calculator, a generator box held 0 and had a floor of 1. Clicking into that box and back out, without typing anything, changed it to 1, and the runtime result changed with it. My fix had its own small version of the bug. I caught it in testing, before the lift station calculator got the new box.
Every field got its own automated test in a real browser, at a desktop width and a phone width. Type a value one key at a time. Clear it and retype it. Leave it untouched. Press Enter. Reload the page. The test fails if the box changes anything I did not ask it to.
What This Means for Your Site
A form that fights the visitor loses the visitor. One person wrote in about this. I have no way of knowing how many others just closed the tab.
Your quote form, contact form or order form can have the same problem. Here is how to check it:
- Open the form on your phone and on a computer.
- Type a real value fast, the way a customer would. A phone number. A ZIP code. A quantity like 1500.
- Watch every keystroke. If the box changes anything before you are done, that is the bug.
- Tab away, then come back. The value should be exactly what you typed, or there should be a plain message telling you why not.
- Clear a box and retype it. Try a 0, a decimal like 0.5 and, where it makes sense, a negative number.
If any step fights you, it fights your customers too.
Does Your Form Fight Back?
ToolGrit is free and needs no login, so try a calculator and type like you mean it. If a form on your own site fails any of the checks above, send me the page and tell me what happened.