Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] When should an "onChange" event actually change?



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?

Thank you for any advice.

--
Dave M G


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links