/    Sign up×
Community /Pin to ProfileBookmark

problem with events

Hello,

I have a problem with events. I tell you:

I have an input element with two events:

<input type=”text” value=”” maxlength=”4″ onchange=”alert(‘test’);” onkeyup=”this.value = this.value.toUpperCase()” />

The problem is that not run the onchange events with the function from the onkeyup event because I rewrite the input value, then it not find the changed values.

I need to use this two events, no others.

Do you know any solution to this problem?

Gracias

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@chrizJul 15.2004 — how about

<input type="text" value="" maxlength="4" on[COLOR=red]C[/COLOR] hange="alert('test');" one[COLOR=red]K[/COLOR]eyup="this.value = this.value.toUpperCase()" />

Just quick line
Copy linkTweet thisAlerts:
@abuenogauthorJul 15.2004 — Sorry, but this is not the problem. ?

Thanks ?
Copy linkTweet thisAlerts:
@AdamGundryJul 15.2004 — What exactly do you want to happen? Do you want the onchange event to run after every keypress? If so, you could combine them like this:

onkeyup="this.value = this.value.toUpperCase(); alert('test');"

If not, can you explain what you want it to do a little more clearly please.

Adam
Copy linkTweet thisAlerts:
@abuenogauthorJul 15.2004 — Hello,

thanks for your comment.

If you test this code:

<input type="text" value="" maxlength="4" onchange="alert('test');" onkeyup="this.value = this.value.toUpperCase()" />

You will see that the event onchange not run. That is because in the event onkeyup I'm rewritting the value of the input.

But I need that this events run correctly with this functions.

Thanks.
Copy linkTweet thisAlerts:
@AdamGundryJul 15.2004 — It seems to work fine in Firefox and Konqueror, so I'm guessing this is an IE bug. I don't have access to IE on this machine, but I'll test it and see if I can come up with anything later.

Adam
Copy linkTweet thisAlerts:
@abuenogauthorJul 15.2004 — Hello

Efectly, it runs perfectly in firefox, but in ie it doesn't. And I need to work in ie... ?.

Do you know any solution to ie?


Thanks for your time.
Copy linkTweet thisAlerts:
@AdamGundryJul 16.2004 — Ok, this is not the most elegant solution but it seems to work in both Firefox and IE:

<input type="text" value="" maxlength="4" onchange="alert('test');"

onkeypress="if (!event.which) event.keyCode = String.fromCharCode(event.keyCode).toUpperCase().charCodeAt(0);"

onkeyup="if (event.which) this.value = this.value.toUpperCase()" />

Adam
×

Success!

Help @abuenog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...