Hi. The following function is returning exactly what is passed to it. For example, if I call formatInput('123456string') it just returns 123456 in the alert box. Does anyone know why this might be happening?
////////////////////////////////////////////
function formatInput(string) {
newstring = string;
newstring.replace("1","-|@|-");
newstring.replace("2","-|#|-");
newstring.replace("3","-|$|-");
newstring.replace("4","-|%|-");
newstring.replace("5","-|^|-");
newstring.replace("6","-|&|-");
newstring.replace("7","-|*|-");
newstring.replace("8","-|(|-");
newstring.replace("9","-|)|-");
newstring.replace("0","-|!|-");
newstring.replace("Z","~!A!~");
newstring.replace("z","~!a!~");
newstring.replace("Y","~!B!~");
newstring.replace("y","~!b!~");
newstring.replace("X","~!C!~");
newstring.replace("x","~!c!~");
newstring.replace("W","~!D!~");
newstring.replace("w","~!d!~");
newstring.replace("V","~!E!~");
newstring.replace("v","~!e!~");
newstring.replace("U","~!F!~");
newstring.replace("u","~!f!~");
newstring.replace("T","~!G!~");
newstring.replace("t","~!g!~");
newstring.replace("S","~!H!~");
newstring.replace("s","~!h!~");
newstring.replace("R","~!I!~");
newstring.replace("r","~!i!~");
newstring.replace("Q","~!J!~");
newstring.replace("q","~!j!~");
newstring.replace("P","~!K!~");
newstring.replace("p","~!k!~");
newstring.replace("O","~!L!~");
newstring.replace("o","~!l!~");
newstring.replace("N","~!M!~");
newstring.replace("n","~!m!~");
newstring.replace("M","~!N!~");
newstring.replace("m","~!n!~");
newstring.replace("L","~!O!~");
newstring.replace("l","~!o!~");
newstring.replace("K","~!P!~");
newstring.replace("k","~!p!~");
newstring.replace("J","~!Q!~");
newstring.replace("j","~!q!~");
newstring.replace("I","~!R!~");
newstring.replace("i","~!r!~");
newstring.replace("H","~!S!~");
newstring.replace("h","~!s!~");
newstring.replace("G","~!T!~");
newstring.replace("g","~!t!~");
newstring.replace("F","~!U!~");
newstring.replace("f","~!u!~");
newstring.replace("E","~!V!~");
newstring.replace("e","~!v!~");
newstring.replace("D","~!W!~");
newstring.replace("d","~!w!~");
newstring.replace("C","~!X!~");
newstring.replace("c","~!x!~");
newstring.replace("B","~!Y!~");
newstring.replace("b","~!y!~");
newstring.replace("A","~!Z!~");
newstring.replace("a","~!z!~");
newstring.replace("!","::exc::");
newstring.replace("@","::ats::");
newstring.replace("#","::num::");
newstring.replace("$","::dol::");
newstring.replace("%",":er::");
newstring.replace("^","::upa::");
newstring.replace("&","::amp::");
newstring.replace("*","::ast::");
newstring.replace("(","::lpa::");
newstring.replace(")","::rpa::");
alert(newstring);
}
////////////////////////////////////////////
////////////////////////////////////////////
function formatInput(string) {
newstring = string;
newstring.replace("1","-|@|-");
newstring.replace("2","-|#|-");
newstring.replace("3","-|$|-");
newstring.replace("4","-|%|-");
newstring.replace("5","-|^|-");
newstring.replace("6","-|&|-");
newstring.replace("7","-|*|-");
newstring.replace("8","-|(|-");
newstring.replace("9","-|)|-");
newstring.replace("0","-|!|-");
newstring.replace("Z","~!A!~");
newstring.replace("z","~!a!~");
newstring.replace("Y","~!B!~");
newstring.replace("y","~!b!~");
newstring.replace("X","~!C!~");
newstring.replace("x","~!c!~");
newstring.replace("W","~!D!~");
newstring.replace("w","~!d!~");
newstring.replace("V","~!E!~");
newstring.replace("v","~!e!~");
newstring.replace("U","~!F!~");
newstring.replace("u","~!f!~");
newstring.replace("T","~!G!~");
newstring.replace("t","~!g!~");
newstring.replace("S","~!H!~");
newstring.replace("s","~!h!~");
newstring.replace("R","~!I!~");
newstring.replace("r","~!i!~");
newstring.replace("Q","~!J!~");
newstring.replace("q","~!j!~");
newstring.replace("P","~!K!~");
newstring.replace("p","~!k!~");
newstring.replace("O","~!L!~");
newstring.replace("o","~!l!~");
newstring.replace("N","~!M!~");
newstring.replace("n","~!m!~");
newstring.replace("M","~!N!~");
newstring.replace("m","~!n!~");
newstring.replace("L","~!O!~");
newstring.replace("l","~!o!~");
newstring.replace("K","~!P!~");
newstring.replace("k","~!p!~");
newstring.replace("J","~!Q!~");
newstring.replace("j","~!q!~");
newstring.replace("I","~!R!~");
newstring.replace("i","~!r!~");
newstring.replace("H","~!S!~");
newstring.replace("h","~!s!~");
newstring.replace("G","~!T!~");
newstring.replace("g","~!t!~");
newstring.replace("F","~!U!~");
newstring.replace("f","~!u!~");
newstring.replace("E","~!V!~");
newstring.replace("e","~!v!~");
newstring.replace("D","~!W!~");
newstring.replace("d","~!w!~");
newstring.replace("C","~!X!~");
newstring.replace("c","~!x!~");
newstring.replace("B","~!Y!~");
newstring.replace("b","~!y!~");
newstring.replace("A","~!Z!~");
newstring.replace("a","~!z!~");
newstring.replace("!","::exc::");
newstring.replace("@","::ats::");
newstring.replace("#","::num::");
newstring.replace("$","::dol::");
newstring.replace("%",":er::");
newstring.replace("^","::upa::");
newstring.replace("&","::amp::");
newstring.replace("*","::ast::");
newstring.replace("(","::lpa::");
newstring.replace(")","::rpa::");
alert(newstring);
}
////////////////////////////////////////////