BUG-15384 Issue in the field check-box from Dynaform with the label.

When a label in a required field has a line break, a js error happens.

When the eval function is applied to the label's string, the line break is taked as the conclusion of the string, and js searchs " (double quotes) which closes the string without finding it and giving the error: "SintaxError: unterminated string literal"

So I use the replace function to change the break line to a simple space, this solves the problem and the error does not happend again.
This commit is contained in:
jennylee
2014-07-23 11:02:39 -04:00
parent 6d70e67ad7
commit ca204e22ec
2 changed files with 2 additions and 1 deletions

View File

@@ -2969,6 +2969,7 @@ var validateForm = function(sRequiredFields) {
* i.ei <form onsubmit="myaction(MyjsString)" ... with var MyjsString = "some string that is into a variable, so this broke the html";
*/
sRequiredFields = sRequiredFields.replace(/\n/g, " ");
if( typeof(sRequiredFields) != 'object' || sRequiredFields.indexOf("%27") > 0 ) {
sRequiredFields = sRequiredFields.replace(/%27/gi, '"');
}

View File

@@ -1209,7 +1209,7 @@ dropdowns=grids[j].getElementsByTagName('select');for(i=0;i<dropdowns.length;i++
fieldGridName=$label[1]+"["+$label[2]+"["+$label[3].split("]")[0];if(!notValidateThisFields.inArray(fieldGridName)){invalidFields.push($fieldName);}
vtext.failed();}else{vtext.passed();}}}
return(invalidFields);};var swSubmitValidateForm=1;var validateForm=function(sRequiredFields){if(swSubmitValidateForm==1){swSubmitValidateForm=0;sFormName=document.getElementById('__DynaformName__');if(typeof(__dynaformSVal__)!='undefined'&&(typeof(sFormName)!='undefined'&&sFormName!='login')&&(typeof(__usernameLogged__)!='undefined'&&__usernameLogged__!='')){if(!sessionPersits()){showPromptLogin('session');swSubmitValidateForm=1;return false;}}
if(typeof(sRequiredFields)!='object'||sRequiredFields.indexOf("%27")>0){sRequiredFields=sRequiredFields.replace(/%27/gi,'"');}
sRequiredFields=sRequiredFields.replace(/\n/g," ");if(typeof(sRequiredFields)!='object'||sRequiredFields.indexOf("%27")>0){sRequiredFields=sRequiredFields.replace(/%27/gi,'"');}
if(typeof(sRequiredFields)!='object'||sRequiredFields.indexOf("%39")>0){sRequiredFields=sRequiredFields.replace(/%39/gi,"'");}
aRequiredFields=eval(sRequiredFields);var sMessage='';var invalid_fields=Array();var fielEmailInvalid=Array();for(var i=0;i<aRequiredFields.length;i++){aRequiredFields[i].label=(aRequiredFields[i].label=='')?aRequiredFields[i].name:aRequiredFields[i].label;if(!notValidateThisFields.inArray(aRequiredFields[i].name)){if(typeof aRequiredFields[i].required!='undefined'){required=aRequiredFields[i].required;}else{required=1;}
if(typeof aRequiredFields[i].validate!='undefined'){validate=aRequiredFields[i].validate;}else{validate='';}