/    Sign up×
Community /Pin to ProfileBookmark

Making Upper Case

I use a function to turn the contents of a string to uppercase.

function uppercase()
{
SearchPropForm.PropSearch.value = SearchPropForm.PropSearch.value.toUpperCase();
}

I call it on the onkeypress event and it changes each letter to uppercase as it is typed.

However, if after typing something you move the cursor back a couple of characters to correct something – and press backspace – the cursor automatically moves to the end of the string – so it is in the wrong place to type your corrected character.

Can anyone tell me how to turn a character into uppercase as you type it rather than turning the whole contents of a field into uppercase.
Thanks for any help.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonJun 19.2004 — Try this:<input type="text" style="text-transform:uppercase;" onblur="this.value=this.value.toUpperCase();">
Copy linkTweet thisAlerts:
@WebskaterauthorJun 20.2004 — Thanks for your reply - but won't that just do what my function does already i.e. turn the whole field to uppercase?

My function turns each character to uppercase as I type but, if you move the cursor back to correct a letter my function moves the cursor to the end of the string as soon as you press a key. I can use my function on the onblur event but it does not do what I want - which is to change a character to uppercase as it is typed - regardless of where in a string the cursor is.
Copy linkTweet thisAlerts:
@PittimannJun 20.2004 — Hi!

I haven't seen lavalamp the whole day so I hope, it is okay, I drop in.

Webskater, just test the example, lavalamp posted for you. It does exactly what you want! It is the style="text-transform:uppercase;" which does the trick (wherever the cursor is).

Cheers - Pit
Copy linkTweet thisAlerts:
@David_HarrisonJun 20.2004 — [i]Originally posted by Pittimann [/i]

[B]I haven't seen lavalamp the whole day so I hope, it is okay, I drop in.[/B][/QUOTE]
No problem at all Pit, I'm also going to be off for a good 3-4 hours after posting this probably.

I guess that today is an off day for me.
Copy linkTweet thisAlerts:
@PittimannJun 20.2004 — Hi!I guess that today is an off day for me.[/QUOTE]Enjoy it! ?

Regards - Pit
Copy linkTweet thisAlerts:
@WebskaterauthorJun 21.2004 — lavalamp, thanks for your answer and pittiman - thanks for telling me to try lavalamp's solution. As you say it works - I did not notice the style="text-transform:uppercase;", I only noticed the onblur bit.

Thanks again.
Copy linkTweet thisAlerts:
@David_HarrisonJun 21.2004 — Happy to help. ?
×

Success!

Help @Webskater 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 5.16,
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,
)...