hi friends..
in an input textfielt i try to reverse writing directions for numbers.
i use only numbers.. i need just a simple code to reverse writing directions as right to left.
I found a code but it is not working.. it is like this;
String.prototype.reverseSpecial = function() {
// ------ Parse text into numeric & string chunks
var chunks = [];
var mode = "";
var lenMax = this.length;
for (var len = 0; len<lenMax; len++) {
if (this.charAt(len)+1 && this.charAt(len) != " ") {
// This character is numeric
if (mode != "num") {
mode = "num";
chunks[chunks.length] = this.charAt(len);
// Start new numeric chunk
} else {
chunks[chunks.length-1] += this.charAt(len);
// Add to current numeric chunk
}
} else {
if (mode != "str") {
mode = "str";
chunks[chunks.length] = this.charAt(len);// Start new text chunk
} else {
chunks[chunks.length-1] += this.charAt(len);// Add to existing text chunk
}
}
}
// ------ Create output : reverse all non-numeric chunks
var outString;
for (var arr in chunks) {
if (String(Number(chunks[arr])) != "NaN") {
} else {
chunks[arr] = chunks[arr].reverseString();
}
outString += chunks[arr];
}
return outString;
};
String.prototype.reverseString = function() {
var out;
var len = this.length;
while (len--) {
out += this.charAt(len);
}
return out;
};
trace("This is a test sentence 1234 this is a test sentence 3.141592".reverseSpecial());
// 3.141592 ecnetnes tset a si siht 1234 ecnetnes tset a si sihT
any idea ????