Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Making first letter of the text uppercase

Posted on 2011-09-20
9
Medium Priority
?
379 Views
Last Modified: 2012-05-12
I have textboxes for data entry. What is the javascript function to make first letter of the text as Uppercase with the rest normally entered as lowercase.
0
Comment
Question by:zachvaldez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 13

Accepted Solution

by:
ansudhindra earned 200 total points
ID: 36568631
you can use this function

function capitaliseFirstLetter(string)
{
    return string.charAt(0).toUpperCase() + string.slice(1);
}

Sudhindra - www.clicksperday.com
0
 
LVL 9

Assisted Solution

by:sshah254
sshah254 earned 200 total points
ID: 36568640
Try this:

http://stackoverflow.com/questions/196972/convert-string-to-proper-case-with-javascript

function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}

SS
0
 
LVL 16

Assisted Solution

by:disrupt
disrupt earned 400 total points
ID: 36568694
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 60

Assisted Solution

by:HainKurt
HainKurt earned 200 total points
ID: 36568698
maybe this help...

(not functioning correctly if you have text, select all and press a new key, which replaces all)
<script>
function up(t, e){
  if (!e) var e = window.event;//alert(e.keyCode);
  if (t.value=="") e.keyCode = (e.keyCode>=97 && e.keyCode<=122)?e.keyCode-32:e.keyCode;
}
</script>

<input id=txt onKeyPress="up(this, event)">

Open in new window

0
 

Author Comment

by:zachvaldez
ID: 36568894
on what event is this use /added as property/funciton in the source?
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 36568903
on blur event
0
 
LVL 16

Assisted Solution

by:disrupt
disrupt earned 400 total points
ID: 36569049
check this out:

  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#<%= TextBox1.ClientID %>').blur(function() {
        $("#<%= TextBox1.ClientID %>").val(capitalize($(this).val()));
        });

        function capitalize(a) {
            newVal = '';
            a = a.split(' ');
            for (var c = 0; c < a.length; c++) {
                newVal += a[c].substring(0, 1).toUpperCase() + a[c].substring(1, a[c].length) + ' '
            }
            return newVal
        }
    });
</script>

Open in new window

0
 

Author Closing Comment

by:zachvaldez
ID: 36570211
too many answers,too little points to spread.Thanks guys
0
 

Author Closing Comment

by:zachvaldez
ID: 36570213
too many answers,too little points to spread.Thanks guys
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question