-4

I want to have only first letter of the sentence to be capitalized in input fields with javascript when i type something.

This is my website link where i want to use it.

Is there any solution for it?

Here is my HTML code:

<div class="form-group">
     <label for="name" class="label-head">Company Name <sup><span
                                class="glyphicon glyphicon-asterisk red" aria-hidden="true"></span></sup></label>
     <input type="text" class="form-control text-box-length input-lg" id="companyname" placeholder="Enter Your Company Name" data-validation="required" maxlength="50">
</div>
Sam
  • 15
  • 2
  • dublicate [Convert first letter to uppercase on input box](http://stackoverflow.com/questions/14688141/convert-first-letter-to-uppercase-on-input-box) – Eriks Sep 14 '16 at 07:21
  • This is not duplicate because i want only first letter to be capitalized not every single word.. – Sam Sep 14 '16 at 08:39

1 Answers1

0

Call this function and set the text to input on each key press

function titleCase(string) { 
return string.charAt(0).toUpperCase() + string.slice(1); 
}
Sasikumar
  • 863
  • 5
  • 9