0

make string initcap like if i enter paul james in textbox it should give me Paul James ..do it with javascript with and without inbuild functions.... make string initcap ?

brief:i dont want to use any inbuilt javaacript function like split and all...i just want to init cap that is "My Name Is In Init Cap"..i want my string in this format withour split and all

<input type="text" placeholder="enter string"/>
   <button>make string uppercase</button><!--like Paul James if i enter paul james-->
  • It is really annoying when websites decide they know better how to spell or capitalize your name, especially if your website is to be used internationally. For example in the Netherlands, certain last names have an 'infix' between first and last name, which should be lower case when both first and last name are present, and only capitalized if the first name is absent. – Mark Rotteveel Sep 19 '15 at 07:43

2 Answers2

1

Why use javascript, when you can use CSS?

button:focus{text-transform:capitalize;}

Example: http://jsfiddle.net/wgLao126/

RealWorldCoder
  • 1,031
  • 1
  • 10
  • 16
0

Its quite simple :

    var a = MakeUpperCase("dean jones");
    function MakeUpperCase(str)
    {
        var strsplt = str.split(" ");
        var completestr ="";
        for(var i=0;i<strsplt.length;i++){
        var d =               strsplt[i].replace(strsplt[i].charAt(0),strsplt[i].charAt(0).toUpperCase());
    completestr += d + " ";
}
alert(completestr);
}