Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 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
Updated 23-Dec-21 1:36am
v3
Comments
joshrduncan2012 21-Dec-12 10:34am    
What have you done to accomplish this so far?

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

Example :
<asp:TextBox style="text-transform:uppercase" runat="server" ID="myTextBox" />
 
Share this answer
 
Comments
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..
[no name] 24-Dec-12 9:31am    
Nice answer...
You can do the uppercase part very simply by using CSS:
HTML
<input id="myInput" style="text-transform: uppercase" type="text" />

The non-numeric as well needs a little more complexity:
HTML
<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;
    }
</script>
....
<input id="yourid" style="text-transform: uppercase" type="text" onkeypress="return noNumerics();"/>


[edit]Wrong name for function![/edit]
 
Share this answer
 
v2
Comments
Member 9511889 22-Dec-12 7:43am    
in asp.net 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...
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;
}
 
Share this answer
 
v2
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900