Click here to Skip to main content
13,299,727 members (60,761 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have to do something like that....

In textbox we can not enter numeric value.if I enter lowercase letter then it automatically convert into uppercase letter.And if I enter uppercase letter then it can accept as it is.

I have to do this using javascript (.js file in solution explorer)

please tell me how to do this..
Posted 21-Dec-12 5:25am
Updated 24-Dec-12 1:54am
joshrduncan2012 21-Dec-12 10:34am
What have you done to accomplish this so far?
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

You can simply use style="text-transform:uppercase" in your textbox declaration.

Example :
<asp:TextBox style="text-transform:uppercase" runat="server" ID="myTextBox" />
GANESH KUMAR K 24-Dec-12 7:08am
wow Super.... @Rajesh Kuramdasu....

I was trying in javascript But it's really superb very small matter.. Thanks alot :-)
Mohan Santhosh 6-Jun-16 6:56am
It's ok ,But lowercase Automatic changed Uppercase letters not store Database,only store lowecase

Then how to slove this problem..
Armando Talex 24-Dec-12 9:31am
Nice answer...
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You can do the uppercase part very simply by using CSS:
<input id="myInput" style="text-transform: uppercase" type="text" />

The non-numeric as well needs a little more complexity:
<script language="JavaScript">
  function noNumerics(evt)
    var e = event || evt;
    var charCode = e.which || e.keyCode;
    if ((charCode >= 48) && (charCode <= 57))
       return false;
    return true;
<input id="yourid" style="text-transform: uppercase" type="text" onkeypress="return noNumerics();"/>

[edit]Wrong name for function![/edit]
Member 9511889 22-Dec-12 7:43am
in c# this code is not working.
onkeypress is not available.

please help me.
OriginalGriff 22-Dec-12 8:01am
Look at the code above: See the bit which starts
script language="JavaScript"
That should be a clue where it goes...
Rate this: bad
Please Sign up or sign in to vote.

Solution 5

it will help to accept non numerical with uppercase.

<asp:TextBox ID="textbox1" runat="server" text-transform: uppercase" onkeypress="return noNumerics(event);" >

function noNumerics(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if ((charCode >= 48) && (charCode <= 57)) {
return false;
return true;
CHill60 22-Jul-15 9:17am
This adds nothing to the solutions that were posted well over 2 years ago. Avoid answering old posts that already have adequate answers unless you have something really new to bring to the discussion
sandeepdhakal 22-Jul-15 9:27am
its an improved one on textbox onkeypress"return noNumerics(event);" is added here .. it will work check again CHill60
CHill60 22-Jul-15 10:14am
If you want to reply to a post you need to use the "Reply" link so that the poster knows you have responded.
I don't see it as a improvement at all - it's essentially identical to Solution 3 (posted over 2 years ago), just using the conditional operator ?: instead of conditional-OR ||
(Given that you have received 2 downvotes already then I'm not the only one with this opinion)
sandeepdhakal 22-Jul-15 13:08pm
yes you are right. i found that it was upped on the page, but not "under the covers". so i do like this

string vclsr =((TextBox)gvdata.Rows[i].FindControl("textbox1")).Text.ToUpper();

the last .ToUpper(); is use to save in uppercase.
i think this time it will work. it work for mine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 22 Jul 2015
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100