slomoman Geschrieben 21. September 2004 Geschrieben 21. September 2004 Von VB erinnere ich mich an eine TRIM() Funktion, die Leerzeichen an Anfang und Ende eines Strings abschneidet. Gibt es eine solche Funktion auch für JavaScript?
kills Geschrieben 21. September 2004 Geschrieben 21. September 2004 schau ma was der google bringt: http://www.js-x.com/javascript/?view=932 <script language="javascript"> <!-- // create the prototype on the String object String.prototype.trim = function() { // skip leading and trailing whitespace // and return everything in between var x=this; x=x.replace(/^\s*(.*)/, "$1"); x=x.replace(/(.*?)\s*$/, "$1"); return x; } // copy 'txtIn' to 'txtOut', trimming off unused whitespace function btnClick() { // get the string value from the 'txtIn' element var s = document.frm1.txtIn.value; // trim the string value and put it into the 'txtOut' element document.frm1.txtOut.value = s.trim(); } //--> </script>
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren
Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde Dich hier an.
Jetzt anmelden