Fonction javascript

sspacy Messages postés 61 Statut Membre -  
sspacy Messages postés 61 Statut Membre -
Quelle est la fonction de javascript qui "élimine" les espaces au début d'une chaine de caractères ?

J'en ai besoin pour un test dans un formulaire.

Merciiiiii
:*)

.::Sspacy.Millevazion: that's my world::.

1 réponse

  1. HackTrack
     
    Voici le code :

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    <script>
    <!-- Author: HackTrack -->
    function trimText(){
    var textToTrim = document.aForm.entree.value;
    var textLength = textToTrim.length;
    var i=0;
    while(i<textToTrim.length){
    var aChar = textToTrim.substring(i,i+1);
    if(aChar!=" "){
    break;
    }
    i++;
    }
    document.aForm.entree.value = textToTrim.substring(i,textToTrim.length);
    document.aForm.submit;
    }
    </script>
    </head>

    <body onLoad="document.aForm.entree.value.trim;">
    <form name="aForm" action="otherPage.html;">
    <input name="entree" type="texte" value=" abcdefgh" />
    <br>
    <button onClick="trimText();">Valider</button>
    </form>

    </body>
    </html>

    ;-)
    HackTrack
    0
    1. sspacy Messages postés 61 Statut Membre
       
      ça m'a l'air costaud ! vu que je suis un manche en javascript mais je vais essayer !!

      Merciiiiii :*)

      .::Sspacy.Millevazion: that's my world::.
      0