/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] 2 bits of code i dnt know how to merge

This:

[CODE]<input type=”text” onkeyup=”showHint if(this.value.length>3){this.value=”;alert(‘The currency code can only contain 3 letters!’);}[/CODE]

And this:

[CODE]<input type=”text” id=”txt1″
onkeyup=”showHint(this.value)”>[/CODE]

I need it so it will run the function after the 3rd letter is typed, and still display an error if more than 3 letters are typed

any idea? ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeJul 02.2007 — This:

[CODE]<input type="text" onkeyup="showHint if(this.value.length>3){this.value='';alert('The currency code can only contain 3 letters!');}[/CODE]

And this:

[CODE]<input type="text" id="txt1"
onkeyup="showHint(this.value)">[/CODE]


I need it so it will run the function after the 3rd letter is typed, and still display an error if more than 3 letters are typed

any idea? ?[/QUOTE]

Limit the text input to a maxlength=3. That way there is no need to use anything to alert anyone about anywhat. They can't enter more than three.

^_^
Copy linkTweet thisAlerts:
@dntelauthorJul 03.2007 — Yep, i've decided to do that, would it just be:

[CODE]<input type="text" maxlength=3>[/CODE]

And i wanted to put that function to run as well because im going to have it so when you click off the text box, its asynchronously checks a database so i need a function to run to make an XmlHttpRequest ?

any ideas?

thanks
×

Success!

Help @dntel 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.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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