Tuesday, December 20, 2005

Javascript / Firefox / onBlur / focus workaround

This is one of those issues that can waste a lot of time and makes you look like an idiot to your boss if you can't fix it.

Occasionally, I have a form where a certain type of data is possible but questionable. An example might be, entering a negative dollar amount on a purchase order. At first thought, it doesn't make sense. You generally can't order anything from a vendor and have them pay you for the privilege. If you go a little further, though, you might be able to use this as a way to correct an error on a previous purchase order.

The way I would like to handle this is to have a javascript confirm box appear warning the user that the value is normally positive. If they decide to continue, the value is accepted as is.

The problem arises when you try to run this code in Firefox. For some reason, the event model for forms in Firefox has been fubar for many years. I've been tracking this bug for 4 years.

Here is a workaround for the issue that doesn't give IE fits either:


function checkValue(fld)
{
var re = /[^\d\.\-]/g;
num = fld.value
num = num.replace(re,"");
fldID = fld.id;

if (num < 0)
{
if (confirm("This is normally a positive number. \nIs it OK to keep this negative value?"))
{
return true;
} else {
setTimeout("document.getElementById(fldID).focus();",1);
setTimeout("document.getElementById(fldID).select();",1);
return false;
}
}
return true;
}


If the code you want to execute is having trouble because of the timing of the events firing, you can wrap the code in the setTimeout function and delay it's execution just enough to get things to work as you would expect.

Sunday, December 18, 2005

Santa Rampage

"No force on earch could stop 100 Santas"

For some reason, I find this unusually funny.

Santarchy.com
Oddly Enough News Article | Reuters.com
Drunken Santa Rampage

Friday, December 16, 2005

Gmail adds contact groups

I've been looking for this feature for a while now. It comes in very handy when you want to broadcast messages to groups of developers by project.

Gmail: Help Center - How do I create a Contact Group?

Thursday, December 01, 2005

Great explanation of website certificates

Mark has posted a really good article explaining how much of a sham the certificate authority industry is. This is one case where I think IT in general just got tired of fighting the know-nothing know-it-alls in the marketing department.

So now we pay over $700 for the right to put a small grapic on our website linked to a few easily forgeable pages that is supposed to let our customers know we are a reputable company.

I'm suprised that Verisign spoofing hasn't turned into a sub-industry for organized cyber crime. They could sell Verisign Spoof Kits to phishers for, oh... say $700? (no checks or credit cards accepted, use Western Union).


Coldfusion Muse

FLUFF: Almost there...

I'm almost a member of the 50+ crowd. Git yerself a copy of FireFox and lend a hand. 1.5 seems pretty zippy.





In order to really get over the hump, though, I think Mozilla.com needs to bring back some of the distribution features that the old Netscape browser had. Specifically, we need the ability to control the rights to change features in the browser. Push distribution across the network would be good, too. And don't forget corporate branding – oh wait, you can already do that with a skin.

Graphic courtesy of Google Analytics