Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] When should an "onChange" event actually change?
- Date: Tue, 17 Aug 2010 15:32:12 +0900
- From: Kyle Hasegawa <kylehase@example.com>
- Subject: Re: [tlug] When should an "onChange" event actually change?
- References: <4C6A237B.9030208@example.com>
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2
On 8/17/2010 2:51 PM, Dave M G wrote:TLUG, Javascript type question here, though this might have to do with browser differences as well. I've got a form that has text fields to enter in a username and password, and a submit button. I'm using Javascript to evaluate the content of the fields, to make the submit button be greyed out until certain criteria are met. For example, ensuring the text is more than 6 characters and so on. When the two fields are filled in and pass all the criteria, the submit button turns green. I use the "onChange" event to call the necessary functions that do the evaluating and change the button style properties. Works basically fine. However, the timing is a little off. If I fill in both fields correctly, the button only turns green if I shift focus away from the text fields. So, I'll type in a user name, switch to the password field and type that in. When I type in the complete password, the button isn't green yet. If I click somewhere else on screen, *then* the button turns green. It's as if "onChange" is behaving like what you might call a "mouse out", or an "onChangeOfFocus". I thought "onChange" mean whenever you changed the content of the text field. It seems to me I've been to sites where the Javascript evaluates the content of a text field as it is typed. Am I not understanding the expected "onChange" behaviour, or is it that I need to do something else, or in a addition, to get more immediate feedback from my Javascript?You might consider using onkeyup instead. It'll evaluate the fields each time a key is released, such as when the user enters their password.You probably know this but it's worth repeating, Javascript is fine for enhancing usability but should never be relied on for validation. It's trivial to submit that form with invalid data even if your Javascript is solid and the submit button is disabled.--KyleHase
- Follow-Ups:
- Re: [tlug] When should an "onChange" event actually change?
- From: Francois Cartegnie
- References:
- [tlug] When should an "onChange" event actually change?
- From: Dave M G
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] When should an "onChange" event actually change?
- Next by Date: Re: [tlug] When should an "onChange" event actually change?
- Previous by thread: Re: [tlug] When should an "onChange" event actually change?
- Next by thread: Re: [tlug] When should an "onChange" event actually change?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links