peterb1985
MIS
I'm trying to format my string into uppercase and remove any alpha characters from the end of the string. For example i have a product code c8728ae which i wan't to format as C8728. I've been experimenting with the following code but it has an error somewhere. Please can someone help me. Any advice welcome.
<script language="javascript">
var str = "c8728ae";
var strUpper = str.toUpperCase();
var strLength = strUpper.length - 1;
for(i=strLength; i>=0; i--){
var tempchr = strUpper.charAt(i);
var tchr = tempchr.charCodeAt(0);
if((tchr => 60) && (tchr <= 90)){
var flag = i+1;
}
}
document.write(strUpper.substring(0,flag));
</script>
<script language="javascript">
var str = "c8728ae";
var strUpper = str.toUpperCase();
var strLength = strUpper.length - 1;
for(i=strLength; i>=0; i--){
var tempchr = strUpper.charAt(i);
var tchr = tempchr.charCodeAt(0);
if((tchr => 60) && (tchr <= 90)){
var flag = i+1;
}
}
document.write(strUpper.substring(0,flag));
</script>