Converting to upper case..

N

Nelson

In my web form, I am converting all lower case letters to upper case when
the user types the characters in the edit boxes. I am achieving that by
injecting client side script (onkeyup event) for each text box. However if
the user types the characters so fast it may not work.. Also there are some
other loopholes in my code. Is there any approach in ASP.Net to make sure
whenever the user types lower case, the data will be converted to upper
case.

My application is written using ASP.Net (VB.Net, Java Script and .Net Frame
Work 1.1 and TE 5.5+)

Thanks for your answers.

Nelson
 
K

Kumar Reddi

You can convert the data in the code behind to uppercase using ToUpper()
method
 
G

Guest

I don't think there is any, because if users have javascript turned off then
you are still back to the same problem. So, its best to always validate on
the sever (which you can control) to conform to your business rules.
 
G

Guest

Or,
you can use asp.net validation regularexpression control and Force them to
type in all caps. This will not allow the form to be submitted if they
don't. This will validate both on server and on client (if enabled). Probably
the best solution
 
B

bruce barker

you could convert on the onsubmit event.


function myOnSubmit()
{
var elist = document.getElementsByTagName("INPUT");
for (var i in elist) elist.value = elist.value.toUpperCase();
return true;
}

<form onsubmit="myOnSubmit()" runat="server">


| In my web form, I am converting all lower case letters to upper case when
| the user types the characters in the edit boxes. I am achieving that by
| injecting client side script (onkeyup event) for each text box. However if
| the user types the characters so fast it may not work.. Also there are
some
| other loopholes in my code. Is there any approach in ASP.Net to make sure
| whenever the user types lower case, the data will be converted to upper
| case.
|
| My application is written using ASP.Net (VB.Net, Java Script and .Net
Frame
| Work 1.1 and TE 5.5+)
|
| Thanks for your answers.
|
| Nelson
|
|
 
Joined
Nov 25, 2008
Messages
1
Reaction score
0
Convert to Upper Case

Hello friends,

U can call this function in keyup or keypress.

function setFormat(txtObj)
{

var id = txtObj.id;
var inp = document.getElementById(id);
var x = inp.value;
inp.value = x.toUpperCase();
}
<asp:TextBox ID="txt1" runat="server"
onkeyup="setFormat(this)" ></asp:TextBox>
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top