Bug 6291: masks with digits that are larger than 4 characters and are not numbers are now correctly formated.

This commit is contained in:
Gustavo Adolfo Cruz Laura
2011-02-28 14:50:26 +00:00
parent 021f6740ee
commit 7a51c11fa8

View File

@@ -445,6 +445,15 @@ function replaceAll( text, busca, reemplaza ){
return text;
}
function isNumberMask (mask){
for ( var key in mask){
if (mask[key]!='#'&&mask[key]!=','&&mask[key]!='.'&&typeof(mask[key])=='string'){
return false;
}
}
return true;
}
this.putFormatNumber =function (evt) {
if((typeof(evt)==="undefined" || evt===0) && me.mask!='' ){
var numberSet=me.element.value.split('.');
@@ -509,26 +518,35 @@ function replaceAll( text, busca, reemplaza ){
///////// end the slice code ... complete with zeros
return;
*/
if (isNumberMask(maskpartInt)){
if(cd < maskpartInt.length && cd >= 4 && cd !=3){
var newnamber='';
var newNumber='';
var cc=1;
//alert (onlynumber);
while (onlynumber > 0){
lastdigito = onlynumber % 10;
if (cc%3==0 && cd != cc){
newnamber = ','+lastdigito.toString() + newnamber;
newNumber = ','+lastdigito.toString() + newNumber;
} else {
newnamber = lastdigito.toString() + newnamber;
newNumber = lastdigito.toString() + newNumber;
}
onlynumber =parseInt(onlynumber / 10);
cc++;
}
if(maskWithoutPto.substr( (maskWithoutPto.length -1) ,maskWithoutPto.length) =="%")
me.element.value = newnamber+' '+maskWithoutPto.substr( (maskWithoutPto.length -1) ,maskWithoutPto.length);
me.element.value = newNumber+' '+maskWithoutPto.substr( (maskWithoutPto.length -1) ,maskWithoutPto.length);
else
me.element.value = newnamber;
me.element.value = newNumber;
} else {
if(maskWithoutPto.substr( (maskWithoutPto.length -1) ,maskWithoutPto.length) =="%")
me.element.value = onlynumber +' '+maskWithoutPto.substr( (maskWithoutPto.length -1) ,maskWithoutPto.length);
var spaceString;
if (me.element.value.substr( (me.element.value.length -1) ,me.element.value.length) == '%' ){
spaceString ='';
} else {
spaceString =' ';
}
me.element.value = onlynumber + spaceString + maskWithoutPto.substr( (maskWithoutPto.length -1) ,maskWithoutPto.length);
}
}
}
}