Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • i would suggest you delete the plugin and reinstall it again.

    Be sure do delete all the /wp-content/plugins/contact-form-7/ folders before installing it again!

    Thread Starter caver

    (@caver)

    yeah it worked!

    i’m gonna keep the thrad un-resolved so see if any of you got a better solutions.

    here is my full code

    <p>Fornavn*<br />
        [text fornavn id:fornavnid] </p>
    
    <p>Efternavn* (skal udfyldes)<br />
        [text efternavn id:efternavnid] </p>
    
    [submit id:sumbmitid]
    
    <script>
    document.getElementById("sumbmitid").addEventListener("click", function(){
    var preFornavn = document.getElementById("fornavnid").value;
    var preEfternavn = document.getElementById("efternavnid").value;
    var preFixedmMellemnavn = preEfternavn.split(' ');
    if( preFixedmMellemnavn.length === 1 ) {
    return preFixedmMellemnavn[0];
    }
    var fixedMellemnavn = preFixedmMellemnavn.slice(0, -1).join(' ');
    var fullFornavn = preFornavn + " " + fixedMellemnavn;
    var fixedEfternavn = preFixedmMellemnavn.slice(-1).join(' ');
    var capitalizedFornavn = fullFornavn.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    var capitalizedEfternavn = fixedEfternavn.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    document.getElementById("fornavnid").value = capitalizedFornavn;
    document.getElementById("efternavnid").value = capitalizedEfternavn;
    });
    </script>
    Thread Starter caver

    (@caver)

    Maybe you can use a event listnener instead?

    <!DOCTYPE html>
    <html>
    <body>
    
    [text text-374 id:t1]
    
    [submit id:myBtn]
    
    <script>
    document.getElementById("myBtn").addEventListener("click", function(){
    var precapitalize = document.getElementById("t1").value;
    var capitalized = precapitalize.substr(0, 1).toUpperCase() + precapitalize.substr(1);
    document.getElementById("t1").value = capitalized;
    });
    </script>
    
    </body>
    </html>
Viewing 3 replies - 1 through 3 (of 3 total)