/    Sign up×
Community /Pin to ProfileBookmark

How can I cancel input box event

Hi guys,

I’ve been trying to do something and it’s killing me because I can’t figure out how to do it properly.

I have an input box. I’m validating as the user types. Basically deleting forbidden characters as they type. I’m doing it with the onkeyup event. Problem is this looks kinda crappy because the character they type appears briefly and then get’s deleted. I want to know how can I cancel the event that writes on the input box so that instead of deleting the character myself, I just cancel the event.

I have no idea if the input box or the window is the one responsible for doing this.

Hope you guys can help me.

Thanks!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meMar 24.2010 — move to onkeydown, return false to prevent key from being "typed"
Copy linkTweet thisAlerts:
@mavalos88authorMar 24.2010 — Awesome, thanks so much!
×

Success!

Help @mavalos88 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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...