[Javascript] Programmatically set onchange event for textbox
Terry Riegel
riegel at clearimageonline.com
Wed Oct 4 07:42:05 CDT 2006
The library prototype.js has a form observer that should do exactly
what you need.
The documentation for prototype doesn't exist, so others have tried
to fill in the missing info. This article explains how to use the
library to observe a form. I like the library as a lot of the cross
browser issues are taken care of.
http://www.sitepoint.com/article/painless-javascript-prototype/2
Terry
On Oct 4, 2006, at 1:24 AM, Brian L. Matthews wrote:
>> <input name="txtCardNumber" type="text" maxlength="16"
>> id="txtCardNumber" />
>> [...]
>> So, I have the following code and when the page loads, I do get
>> the "Textbox
>> found" message. However, when I type in the text box, I do not get
>> the "Card
>> Number Typed" alert.
>
> 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).
>
> Brian
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list