[Javascript] Programmatically set onchange event for textbox

Glenn E. Lanier, II glenn_lanier at netzero.net
Wed Oct 4 10:04:58 CDT 2006


> From: Matt Warden
> Sent: Wednesday, October 04, 2006 9:56 AM

> On 10/4/06, Glenn E. Lanier, II <glenn_lanier at netzero.net> wrote:
> > > -----Original Message-----
> > > From: Brian L. Matthews
> > > Sent: Wednesday, October 04, 2006 12:25 AM
> >
> > > onchange only fires when the field loses focus (i.e. you 
> tab out or
> > > click the page somewhere outside the field). That's often 
> sufficient
> > > (it usually doesn't make sense to do field validation on 
> a partially
> > > typed field). If you want to validate the first digit as 
> soon as it's
> > > typed, look into the onkey events, but make sure you read about
> > > browser compatibility (<http://www.quirksmode.org/> is a 
> good site,
> > > I'm sure there are others).
> >
> > Thanks. That would have given me some grief.
> 
> You would be better off using a timeout approach, otherwise your
> events are tied to typing speed of the user, which typically makes no
> sense for what you're trying to do.

Matt,

This is just eye candy for the client. I have four radio buttons aligned
with credit card images (Visa, Mastercard, etc). They want to auto select
the radio button based on the credit card number entered -- yes, I've
already explained that there is no need to even require the user to select
the type of credit card, and if they check Visa, but enter AmEx number,
client wants to process card number entered. If I select the card type on
the second (or 10th) digit, no big deal (in this case).

--G




More information about the Javascript mailing list