BUG 8883 en IE9 al habilitar el script debugging muestra un error ... SOLVED
- Al habilitar del debug en IE saltaba un error de keyCode, ya que ese evento no era propio para IE. - Se hicieron cambios para poder detectar los diferentes eventos que tiene IE, firefox, Chrome y validar el keyCode, ademas de la validacion se aumento en el validator.js el campo NodeName para poder hacer la verificacion completa de ese campo.
This commit is contained in:
@@ -1119,7 +1119,8 @@ function G_Text( form, element, name)
|
|||||||
}
|
}
|
||||||
//THIS FUNCTION HANDLE BACKSPACE AND DELETE KEYS
|
//THIS FUNCTION HANDLE BACKSPACE AND DELETE KEYS
|
||||||
if (me.validate == 'Any' && me.mask == '') return true;
|
if (me.validate == 'Any' && me.mask == '') return true;
|
||||||
pressKey = event.keyCode;
|
//pressKey = event.keyCode;
|
||||||
|
pressKey = window.event ? window.event.keyCode : event.which;
|
||||||
switch(pressKey){
|
switch(pressKey){
|
||||||
case 8: case 46: //BACKSPACE OR DELETE
|
case 8: case 46: //BACKSPACE OR DELETE
|
||||||
case 35: case 36: //HOME OR END
|
case 35: case 36: //HOME OR END
|
||||||
@@ -1136,7 +1137,7 @@ function G_Text( form, element, name)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.handleKeyPress = function(event){
|
this.handleKeyPress = function(event){
|
||||||
if (me.element.readOnly) {
|
if (me.element.readOnly) {
|
||||||
@@ -1147,15 +1148,24 @@ function G_Text( form, element, name)
|
|||||||
}
|
}
|
||||||
if (me.validate == 'Any' && me.mask == '') return true;
|
if (me.validate == 'Any' && me.mask == '') return true;
|
||||||
//THIS FUNCTION HANDLE ALL KEYS EXCEPT BACKSPACE AND DELETE
|
//THIS FUNCTION HANDLE ALL KEYS EXCEPT BACKSPACE AND DELETE
|
||||||
keyCode = event.keyCode;
|
//keyCode = event.keyCode;
|
||||||
|
keyCode = window.event ? window.event.keyCode : event.which;
|
||||||
switch(keyCode){
|
switch(keyCode){
|
||||||
case 9: case 13:
|
case 9: case 13:
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (event.altKey) return true;
|
if (window.event) {
|
||||||
if (event.ctrlKey) return true;
|
if (window.event.altKey) return true;
|
||||||
if (event.shiftKey) return true;
|
if (window.event.ctrlKey) return true;
|
||||||
|
if (window.event.shiftKey) return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (event.altKey) return true;
|
||||||
|
if (event.ctrlKey) return true;
|
||||||
|
if (event.shiftKey) return true;
|
||||||
|
}
|
||||||
|
|
||||||
me.checkBrowser();
|
me.checkBrowser();
|
||||||
if ((me.browser.name == 'Firefox') && (keyCode == 8 || keyCode == 46)){
|
if ((me.browser.name == 'Firefox') && (keyCode == 8 || keyCode == 46)){
|
||||||
if (me.browser.name == 'Chrome' || me.browser.name == 'Safari'){
|
if (me.browser.name == 'Chrome' || me.browser.name == 'Safari'){
|
||||||
@@ -1166,7 +1176,8 @@ function G_Text( form, element, name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
pressKey = window.event ? event.keyCode : event.which;
|
//pressKey = window.event ? event.keyCode : event.which;
|
||||||
|
pressKey = window.event ? window.event.keyCode : event.which;
|
||||||
if (me.mType == 'date') me.validate = 'Int';
|
if (me.mType == 'date') me.validate = 'Int';
|
||||||
keyValid = true;
|
keyValid = true;
|
||||||
updateOnChange = true;
|
updateOnChange = true;
|
||||||
@@ -1224,16 +1235,16 @@ function G_Text( form, element, name)
|
|||||||
}
|
}
|
||||||
var k=new leimnud.module.validator({
|
var k=new leimnud.module.validator({
|
||||||
valid :['Login'],
|
valid :['Login'],
|
||||||
key :event,
|
key : (window.event)? window.event : event,
|
||||||
lang :(typeof(me.language)!=='undefined')?me.language:"en"
|
lang :(typeof(me.language)!=='undefined')? me.language:"en"
|
||||||
});
|
});
|
||||||
keyValid = k.result();
|
keyValid = k.result();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var k = new leimnud.module.validator({
|
var k = new leimnud.module.validator({
|
||||||
valid :[me.validate],
|
valid :[me.validate],
|
||||||
key :event,
|
key :(window.event) ? window.event : event,
|
||||||
lang :(typeof(me.language)!=='undefined')?me.language:"en"
|
lang :(typeof(me.language)!=='undefined')? me.language:"en"
|
||||||
});
|
});
|
||||||
keyValid = k.result();
|
keyValid = k.result();
|
||||||
|
|
||||||
|
|||||||
@@ -1,163 +1,164 @@
|
|||||||
leimnud.Package.Public({
|
leimnud.Package.Public({
|
||||||
info :{
|
info :{
|
||||||
Class :"maborak",
|
Class :"maborak",
|
||||||
File :"module.validator.js",
|
File :"module.validator.js",
|
||||||
Name :"validator",
|
Name :"validator",
|
||||||
Type :"module",
|
Type :"module",
|
||||||
Version :"1.4"
|
Version :"1.4"
|
||||||
},
|
},
|
||||||
content :function(param)
|
content :function(param)
|
||||||
{
|
{
|
||||||
this.valid=param.valid || false;
|
this.valid=param.valid || false;
|
||||||
this.invalid=param.invalid || false;
|
this.invalid=param.invalid || false;
|
||||||
this.validArray=(this.valid.isArray)?this.valid:[];
|
this.validArray=(this.valid.isArray)?this.valid:[];
|
||||||
this.invalidArray=(this.invalid.isArray)?this.invalid:[];
|
this.invalidArray=(this.invalid.isArray)?this.invalid:[];
|
||||||
this.add=param.add || false;
|
this.add=param.add || false;
|
||||||
this.generateKeys=function()
|
this.generateKeys=function()
|
||||||
{
|
{
|
||||||
this.keys=[];
|
this.keys=[];
|
||||||
this.keys['es']=[];
|
this.keys['es']=[];
|
||||||
this.keys["es"]["Alpha"]=["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","áéíóúñÁÉÍÓÚÑüïÜÏ"," "];
|
this.keys["es"]["Alpha"]=["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","áéíóúñÁÉÍÓÚÑüïÜÏ"," "];
|
||||||
this.keys["es"]["Int"]=[[47,57]].concat("+-");
|
this.keys["es"]["Int"]=[[47,57]].concat("+-");
|
||||||
this.keys["es"]["Real"]=[[48,57]].concat(".,-+");
|
this.keys["es"]["Real"]=[[48,57]].concat(".,-+");
|
||||||
this.keys["es"]["Any"]=this.keys["es"]["Alpha"].concat("!#$%&/()=???+*{}[]-_.:,;'|\"\\@",[[48,57]]);
|
this.keys["es"]["Any"]=this.keys["es"]["Alpha"].concat("!#$%&/()=???+*{}[]-_.:,;'|\"\\@",[[48,57]]);
|
||||||
this.keys["es"]["AlphaNum"]=this.keys['es']["Int"].concat(this.keys["es"]["Alpha"][0],this.keys["es"]["Alpha"][1]," ");
|
this.keys["es"]["AlphaNum"]=this.keys['es']["Int"].concat(this.keys["es"]["Alpha"][0],this.keys["es"]["Alpha"][1]," ");
|
||||||
this.keys["es"]["Field"]=["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"];
|
this.keys["es"]["Field"]=["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"];
|
||||||
this.keys["es"]["Email"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
this.keys["es"]["Email"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
||||||
this.keys["es"]["Login"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
this.keys["es"]["Login"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
||||||
this.keys["es"]["Path"]=this.keys['es']["Field"].concat("/"," ");
|
this.keys["es"]["Path"]=this.keys['es']["Field"].concat("/"," ");
|
||||||
this.keys["es"]["Tag"]=this.keys['es']["Field"].concat(","," ");
|
this.keys["es"]["NodeName"]=this.keys['es']["Field"].concat("-");
|
||||||
|
|
||||||
this.keys["en"]=[];
|
this.keys["en"]=[];
|
||||||
this.keys["en"]["Alpha"]=[this.keys["es"]["Alpha"][0]];
|
this.keys["en"]["Alpha"]=[this.keys["es"]["Alpha"][0]];
|
||||||
this.keys["en"]["Int"]=[[48,57]].concat("+-");
|
this.keys["en"]["Int"]=[[48,57]].concat("+-");
|
||||||
this.keys["en"]["Real"]=[[48,57]].concat(".,-+");
|
this.keys["en"]["Real"]=[[48,57]].concat(".,-+");
|
||||||
this.keys["en"]["Any"]=this.keys["en"]["Alpha"].concat("!#$%&/()=???+*{}[]-_.:,;'|\"\\@",[[48,57]]);
|
this.keys["en"]["Any"]=this.keys["en"]["Alpha"].concat("!#$%&/()=???+*{}[]-_.:,;'|\"\\@",[[48,57]]);
|
||||||
this.keys["en"]["AlphaNum"]=this.keys['en']["Int"].concat(this.keys["en"]["Alpha"][0]," ");
|
this.keys["en"]["AlphaNum"]=this.keys['en']["Int"].concat(this.keys["en"]["Alpha"][0]," ");
|
||||||
//this.keys["en"]["AlfaNum"]=this.keys['en']["Int"];
|
//this.keys["en"]["AlfaNum"]=this.keys['en']["Int"];
|
||||||
this.keys["en"]["Field"]=this.keys["es"]["Field"];
|
this.keys["en"]["Field"]=this.keys["es"]["Field"];
|
||||||
this.keys["en"]["Email"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
this.keys["en"]["Email"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
||||||
this.keys["en"]["Login"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
this.keys["en"]["Login"]=[this.keys["es"]["Alpha"][0]].concat("._-@1234567890");
|
||||||
this.keys["en"]["Path"]=this.keys['es']["Field"].concat("/"," ");
|
this.keys["en"]["Path"]=this.keys['es']["Field"].concat("/"," ");
|
||||||
this.keys["en"]["Tag"]=this.keys['es']["Field"].concat(","," ");
|
this.keys["en"]["Tag"]=this.keys['es']["Field"].concat(","," ");
|
||||||
|
this.keys["en"]["NodeName"]=this.keys['es']["Field"].concat("-");
|
||||||
|
|
||||||
|
|
||||||
return (this.keys[this.lang][this.type])?this.keys[this.lang][this.type]:this.keys[this.lang]["Alpha"];
|
return (this.keys[this.lang][this.type])?this.keys[this.lang][this.type]:this.keys[this.lang]["Alpha"];
|
||||||
};
|
};
|
||||||
this.result=function()
|
this.result=function()
|
||||||
{
|
{
|
||||||
if(this.validArray[0].toLowerCase()=="any")
|
if(this.validArray[0].toLowerCase()=="any")
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(this.isNumber(param.key))
|
if(this.isNumber(param.key))
|
||||||
{
|
{
|
||||||
this.key=param.key;
|
this.key=param.key;
|
||||||
}
|
}
|
||||||
else if(typeof param.key=="object")
|
else if(typeof param.key=="object")
|
||||||
{
|
{
|
||||||
this.key=(param.key.which) ?param.key.which : param.key.keyCode;
|
this.key=(param.key.which) ?param.key.which : param.key.keyCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.key=false;
|
this.key=false;
|
||||||
}
|
}
|
||||||
this.lang= param.lang || "en";
|
this.lang= param.lang || "en";
|
||||||
|
|
||||||
var valid=true;
|
var valid=true;
|
||||||
for(var i=0;i<this.validArray.length;i++)
|
for(var i=0;i<this.validArray.length;i++)
|
||||||
{
|
{
|
||||||
this.type=this.validArray[i];
|
this.type=this.validArray[i];
|
||||||
//alert(this.generateKeys().toStr(true))
|
//alert(this.generateKeys().toStr(true))
|
||||||
valid=this.engine(this.generateKeys());
|
valid=this.engine(this.generateKeys());
|
||||||
if(valid===true){return true;}
|
if(valid===true){return true;}
|
||||||
}
|
}
|
||||||
if(this.validArray.length===0)
|
if(this.validArray.length===0)
|
||||||
{
|
{
|
||||||
valid=this.engine([])
|
valid=this.engine([])
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
};
|
};
|
||||||
this.isNumber=function(a)
|
this.isNumber=function(a)
|
||||||
{
|
{
|
||||||
return (a>=0)?true:false;
|
return (a>=0)?true:false;
|
||||||
};
|
};
|
||||||
this.compareChar=function(_string,car) {
|
this.compareChar=function(_string,car) {
|
||||||
var i = 0,a=false;
|
var i = 0,a=false;
|
||||||
//alert(_string+":"+car)
|
//alert(_string+":"+car)
|
||||||
while ( i <_string.length && !a ) {
|
while ( i <_string.length && !a ) {
|
||||||
//alert(_string[i]+":"+(_string.charCodeAt(i))+":"+car);
|
//alert(_string[i]+":"+(_string.charCodeAt(i))+":"+car);
|
||||||
a= (_string.charCodeAt(i) == car);
|
a= (_string.charCodeAt(i) == car);
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
//alert(a)
|
//alert(a)
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
this.isAlfaUS=function()
|
this.isAlfaUS=function()
|
||||||
{
|
{
|
||||||
patron=[];
|
patron=[];
|
||||||
patron[0]=validator.keys.alfa[0];
|
patron[0]=validator.keys.alfa[0];
|
||||||
patron[1]=validator.keys.alfa[2];
|
patron[1]=validator.keys.alfa[2];
|
||||||
return patron;
|
return patron;
|
||||||
};
|
};
|
||||||
this.isAlfa=function()
|
this.isAlfa=function()
|
||||||
{
|
{
|
||||||
patron=validator.keys.alfa;
|
patron=validator.keys.alfa;
|
||||||
return patron;
|
return patron;
|
||||||
};
|
};
|
||||||
this.checkAdd=function(p)
|
this.checkAdd=function(p)
|
||||||
{
|
{
|
||||||
if(this.add)
|
if(this.add)
|
||||||
{
|
{
|
||||||
return p.concat(this.add)
|
return p.concat(this.add)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.engine=function(p)
|
this.engine=function(p)
|
||||||
{
|
{
|
||||||
//alert(this.lang+":"+leimnud.tools.object.toString(p))
|
//alert(this.lang+":"+leimnud.tools.object.toString(p))
|
||||||
this.patron=this.checkAdd(p);
|
this.patron=this.checkAdd(p);
|
||||||
//alert(p);
|
//alert(p);
|
||||||
//alert(leimnud.tools.object.toString(this.patron))
|
//alert(leimnud.tools.object.toString(this.patron))
|
||||||
var valid=false;
|
var valid=false;
|
||||||
//$("d").innerHTML=" ";
|
//$("d").innerHTML=" ";
|
||||||
//alert(this.patron.toStr(true))
|
//alert(this.patron.toStr(true))
|
||||||
for(var i=0;i<this.patron.length;i++)
|
for(var i=0;i<this.patron.length;i++)
|
||||||
{
|
{
|
||||||
var b=this.patron[i];
|
var b=this.patron[i];
|
||||||
//alert(this.patron[i])
|
//alert(this.patron[i])
|
||||||
var type= typeof this.patron[i];
|
var type= typeof this.patron[i];
|
||||||
if(type=="string")
|
if(type=="string")
|
||||||
{
|
{
|
||||||
// alert(556)
|
// alert(556)
|
||||||
valid=this.compareChar(this.patron[i],this.key);
|
valid=this.compareChar(this.patron[i],this.key);
|
||||||
}
|
}
|
||||||
else if (type=="object")
|
else if (type=="object")
|
||||||
{
|
{
|
||||||
//alert(this.patron[i]);
|
//alert(this.patron[i]);
|
||||||
// alert(this.key+":"+this.patron[i][0]+":"+this.patron[i][1])
|
// alert(this.key+":"+this.patron[i][0]+":"+this.patron[i][1])
|
||||||
valid=(this.key>=this.patron[i][0] && this.key<=this.patron[i][1])?true:false;
|
valid=(this.key>=this.patron[i][0] && this.key<=this.patron[i][1])?true:false;
|
||||||
}
|
}
|
||||||
else if(type=="number")
|
else if(type=="number")
|
||||||
{
|
{
|
||||||
if(this.keys[this.lang]['validatorByLetter'])
|
if(this.keys[this.lang]['validatorByLetter'])
|
||||||
{
|
{
|
||||||
//valid=(String.fromCharCode(this.key)==String.fromCharCode(this.patron[i]))?true:false;
|
//valid=(String.fromCharCode(this.key)==String.fromCharCode(this.patron[i]))?true:false;
|
||||||
valid=(this.key==this.patron[i])?true:false;
|
valid=(this.key==this.patron[i])?true:false;
|
||||||
//$("d").innerHTML+="[ "+String.fromCharCode(this.key)+" : "+String.fromCharCode(this.patron[i])+" [mykey:"+String.fromCharCode(this.patron[i]).charCodeAt(0)+"] ] [2007]["+this.key+"]["+this.patron[i]+"]<br> ";
|
//$("d").innerHTML+="[ "+String.fromCharCode(this.key)+" : "+String.fromCharCode(this.patron[i])+" [mykey:"+String.fromCharCode(this.patron[i]).charCodeAt(0)+"] ] [2007]["+this.key+"]["+this.patron[i]+"]<br> ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valid=(this.key==this.patron[i])?true:false;
|
valid=(this.key==this.patron[i])?true:false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(valid===true){return true;}
|
if(valid===true){return true;}
|
||||||
}
|
}
|
||||||
//alert(valid)
|
//alert(valid)
|
||||||
return valid;
|
return valid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user