﻿/* ----------------------------------------------------------------------------------- 
------- Trim(), LTrim(), RTrim() ----------------------------------------------------- 
------- 
------- Metodi per l'oggetto String, restituiscono la stringa cui sono applicati 
------- senza spazi iniziali e/o finali: 
------- 
------- str_a = stringa.Trim(); 
------- str_a contiene il valore di stringa senza spazi iniziali ne' finali 
------- 
------- str_a = stringa.LTrim(); 
------- str_a contiene il valore di stringa senza spazi iniziali 
------- 
------- str_a = stringa.RTrim(); 
------- str_a contiene il valore di stringa senza spazi finali 
------- 
------- N.B. 
------- [\s] nelle RegExp contiene sia gli spazi che i ritorni a capo, avanzamento riga 
------- tabulatore, tabulatore verticale. Tutti questi caratteri, se presenti, verranno 
------- eliminati. 
------- --- */
function Trim() {
    return this.replace(/\s+$|^\s+/g, "");
}

function LTrim() {
    return this.replace(/^\s+/, "");
}

function RTrim() {
    return this.replace(/\s+$/, "");
}

function IsNumeric() {
    var ValidChars = "0123456789.";
    var IsNumber = true;
    var Char;


    for (i = 0; i < this.length && IsNumber == true; i++) {
        Char = this.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
        }
    }
    return IsNumber;

}



String.prototype.Trim = Trim;
String.prototype.RTrim = RTrim;
String.prototype.LTrim = LTrim;
String.prototype.IsNumeric = IsNumeric;

/* ----------------------------------------------------------------------------------- */ 
 



