Gotta do the trick. Now it works wherever there are carriages, and even when you copy / paste WECZ into the field (if that matters)
var conversionMap = {W:1,E:2,R:3,S:4,D:5,F:6,Z:7,X:8,C:9};
function alphaToNum(){
var field = document.getElementById('idMyText');
var value = field.value.split('');
var i = 0, len = value.length;
for(i;i<len;i++){
if (conversionMap[value[i]]) {
value[i] = conversionMap[value[i]];
}
}
field.value = value.join('');
field = null;
}
** Edit after comment by Tim Downs **
source
share