BUG 9438 Don't add ceros the mask in the fields SOLVED

- I add code for add ceros in the fields
This commit is contained in:
Brayan Osmar Pereyra Suxo
2012-07-11 18:53:53 -04:00
parent b18a424295
commit 9a1c4e6f72
2 changed files with 52 additions and 58 deletions

View File

@@ -334,6 +334,7 @@ function G_Text( form, element, name)
this.mType = 'text'; this.mType = 'text';
this.parent = G_Field; this.parent = G_Field;
this.browser = {}; this.browser = {};
this.comma_separator = ".";
this.checkBrowser = function(){ this.checkBrowser = function(){
var nVer = navigator.appVersion; var nVer = navigator.appVersion;
@@ -1044,6 +1045,7 @@ function G_Text( form, element, name)
} }
} }
switch(action){ switch(action){
case 'mask': case 'move': case 'mask': case 'move':
dataNewMask = me.replaceMasks(newValue, newCursor); dataNewMask = me.replaceMasks(newValue, newCursor);
@@ -1232,19 +1234,6 @@ function G_Text( form, element, name)
patron = /[0-9,\.]/; patron = /[0-9,\.]/;
} }
if (me.mType == 'text') {
me.comma_separator = '';
patron = /[0-9\-]/;
txtRealMask = me.mask.split('');
p = txtRealMask.length - 1;
for ( ; p >= 0; p--) {
if (txtRealMask[p] != '#' && txtRealMask[p] != '%' && txtRealMask[p] != ' ') {
me.comma_separator = txtRealMask[p];
break;
}
}
}
key = String.fromCharCode(pressKey); key = String.fromCharCode(pressKey);
keyValid = patron.test(key); keyValid = patron.test(key);
keyValid = keyValid || (pressKey == 45); keyValid = keyValid || (pressKey == 45);
@@ -1352,6 +1341,8 @@ function G_Text( form, element, name)
} }
} }
var partsMaskSep = me.mask.split(separatorField);
if (partsMaskSep.length == 2) {
var countDecimal = 0; var countDecimal = 0;
txtRealMask = me.mask.split(''); txtRealMask = me.mask.split('');
p = txtRealMask.length - 1; p = txtRealMask.length - 1;
@@ -1374,7 +1365,7 @@ function G_Text( form, element, name)
var newPluginDecimal = ''; var newPluginDecimal = '';
var decimalCade = numberSet[0].split(''); var decimalCade = numberSet[0].split('');
for (p = 0; p < decimalCade.length; p++) { for (p = 0; p < decimalCade.length; p++) {
if (!isNaN(parseFloat(decimalCade[p])) && isFinite(decimalCade[p])) { if ((!isNaN(parseFloat(decimalCade[p])) && isFinite(decimalCade[p])) || (decimalCade[p] == ',') || (decimalCade[p] == '.') ) {
newInt += decimalCade[p]; newInt += decimalCade[p];
} else { } else {
newPluginDecimal += decimalCade[p]; newPluginDecimal += decimalCade[p];
@@ -1403,6 +1394,7 @@ function G_Text( form, element, name)
me.element.value = numberSet[0] + separatorField + decimalString + pluginDecimal; me.element.value = numberSet[0] + separatorField + decimalString + pluginDecimal;
} }
} }
}
if(this.validate=="Email") if(this.validate=="Email")
{ {

View File

@@ -968,6 +968,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
var $function = ''; var $function = '';
var $replaceTags = 0; var $replaceTags = 0;
var $renderMode = ''; var $renderMode = '';
var $comma_separator = '.';
/** /**
@@ -1012,6 +1013,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
$html .= 'onkeypress="'.$this->htmlentities($onkeypress, ENT_COMPAT, 'utf-8').'" '; $html .= 'onkeypress="'.$this->htmlentities($onkeypress, ENT_COMPAT, 'utf-8').'" ';
$html .= $this->NSDefaultValue().' '; $html .= $this->NSDefaultValue().' ';
$html .= $this->NSRequiredValue().' '; $html .= $this->NSRequiredValue().' ';
$html .= 'pm:decimal_separator="' + $this->comma_separator + '" ';
$html .= '/>'; $html .= '/>';
}else{ //VIEW MODE }else{ //VIEW MODE
$html .= $this->htmlentities($value, ENT_QUOTES, 'utf-8'); $html .= $this->htmlentities($value, ENT_QUOTES, 'utf-8');