473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Capitalize small alphabet

vikas251074
198 100+
If a user types either small or capital alphabets in <input type="text"/> tag, then it should become all capital. Can this be done using javascript?

Thanks and regards,
Vikas
Jun 7 '08 #1
6 1581
veenna
65
You can use String.toUpperCase(); to convert string to uppercase.
Jun 7 '08 #2
vikas251074
198 100+
I have written as follows.

Created a function capital() in javascript tag like this

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function capital(temp){
  3.   return String.toUpperCase(temp); 
  4. }
  5. </script>
And called this function like this

Expand|Select|Wrap|Line Numbers
  1. <td align="left"><input type="text" style="width:250px " name="vlan_name" onchange="return capital(this);"/></td>
Also I used onblur event in place of onchange event.

It does not work.

Thanks and regards,
Vikas
Jun 7 '08 #3
veenna
65
You can use this function

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function capital(temp){
  3.     var str=temp.value
  4.   document.getElementById('vlan_name').value = str.toUpperCase(); 
  5. }
  6. </script>


and call function as

[HTML]<input type="text" style="width:250px " name="vlan_name" id="vlan_name" onkeyup="capital(this);"/>[/HTML]



thanks

Veenna
Jun 7 '08 #4
vikas251074
198 100+
Yes, you are right madam,

My problem is solved. But this function (capital()) can not be used multiple times for other <input tag>. How can I do this?

Suppose there are three fields,
vlan_name, vlan_location, vlan_type.
Then I want to use capital() in all three cases.

This line
document.getElementById('vlan_name').value = str.toUpperCase();
makes difficult for using multiple times.

Thanks and regards
Vikas
Jun 7 '08 #5
veenna
65
Instead of
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('vlan_name').value = str.toUpperCase(); 

use

Expand|Select|Wrap|Line Numbers
  1. document.getElementById(temp.id).value = str.toUpperCase();
Jun 7 '08 #6
vikas251074
198 100+
Thanks very much madam. It is great to get answer from u.

Thanks and regards,
Vikas
Jun 7 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rick | last post by:
For some reason my function to capitalize the first letter in a string and keep all the other letters lowercase isn't working. This is what I have. string convname(string name) { int len;...
5
by: Stefan Krah | last post by:
Hello, I am currently writing code where it is convenient to convert char to int . The conversion function relies on a character set with contiguous alphabets. int set_mesg(Key *key, char...
8
by: Jack Addington | last post by:
I want to scroll through the alphabet in order to scroll some data to the closest name that starts with a letter. If the user hits the H button then it should scroll to the letter closest to H. ...
12
by: jackson.rayne | last post by:
Hello, I am a javascript newbie and I'm stick at one place. I have a requirement where I will get a sentence in a variable example var v1 ="This is a sentence"
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.