Veröffentlicht 21. September 200420 j 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?
21. September 200420 j 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>
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.