1function validatePassword(objForm, strName, strErrMsg, bReturnValue){ 2 var bResult = false, 3 //RegExp = /[a-zA-Z0-9\-]/g, 4 RegExp = /^[a-zA-Z0-9\*\$\@\&\(\)\[\]\{\}\=\#\.\-\!\?\+\/\£\\%]+$/g, 5 bConfirmError = false, 6 strPassword = objForm[strName].value; 7 if ( strPassword.length >= 4 && strPassword.length <= 14 ) { 8 if ( RegExp.test(strPassword) ) { 9 bResult = true; 10 } 11 } 12 if ( bResult == false ) { 13 objForm[strName].focus(); 14 if ( bReturnValue == true ) { 15 return bResult; 16 } else { 17 alert(strErrMsg); 18 } 19 } 20 return bResult; 21} 22// OX3609 { 23function validateUserPasswordPolicy(objForm, strName, strErrMsg, bReturnValue) { 24 var bResult = false; 25 var strPassword = objForm[strName].value; 26 var RegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\*\$\@\&\(\)\[\]\{\}\=\#\.\-\!\?\+\/\£\\%])[a-zA-Z\d\*\$\@\&\(\)\[\]\{\}\=\#\.\-\!\?\+\/\£\\%]{8,20}$/; 27 if (strPassword.length >= 0) { 28 if (RegExp.test(strPassword)) { 29 bResult = true; 30 } 31 } 32 if (bResult == false) { 33 objForm[strName].focus(); 34 if (bReturnValue == true) { 35 return bResult; 36 } else { 37 alert(strErrMsg); 38 } 39 } 40 return bResult; 41} 42// Segment 1 = 8, 20 alpha sans accents et/ou carac spé 43// Segment 2 = au moins 1 MAJUSCULE 44// Segment 3 = au moins 1 minuscule 45// Segment 4 = au moins 1 chiffre 46// Segment 5 = au moins 1 carac spé 47function validateUserPasswordPolicyBySegment(strPassword, nSegment) { 48 var bResult = false; 49 var RegExp; 50 if (strPassword.length >= 0) { 51 bResult = true; 52 switch (nSegment) { 53 case 1: 54 // MinMax authorized caracs 55 RegExp = /^[a-zA-Z\d\*\$\@\&\(\)\[\]\{\}\=\#\.\-\!\?\+\/\£\\%]{8,20}$/; 56 break; 57 case 2: 58 // at least 1 UPPER 59 RegExp = /(?=.*[A-Z])/; 60 break; 61 case 3: 62 // at least 1 lower 63 RegExp = /(?=.*[a-z])/; 64 break; 65 case 4: 66 // at least 1 digit 67 RegExp = /(?=.*\d)/; 68 break; 69 case 5: 70 // at least 1 special char 71 RegExp = /(?=.*[\*\$\@\&\(\)\[\]\{\}\=\#\.\-\!\?\+\/\£\\%])/; 72 break; 73 default: 74 bResult = false; 75 } 76 //console.log(RegExp); 77 if (bResult) 78 bResult = RegExp.test(strPassword); 79 } 80 return bResult; 81} 82function checkRealTimePasswordPolicy(strCtrlPassword) { 83 var objForm = document.MForm; 84 var strPassword = objForm[strCtrlPassword].value; 85 // console.log(strPassword); 86 for (var i = 1; i <= 5; i++) { 87 bResult = validateUserPasswordPolicyBySegment(strPassword, i); 88 // console.log(bResult); 89 decorateSegmentPolicy(i, bResult); 90 } 91} 92function decorateSegmentPolicy(nSegment, bMatch) { 93 var strCtrl; 94 switch (nSegment) { 95 case 1: 96 // MinMaxAuthorized caracs 97 strCtrl = "PwdPolicyMinMax"; 98 break; 99 case 2: 100 // at least 1 UPPER 101 strCtrl = "PwdPolicyUpper"; 102 break; 103 case 3: 104 // at least 1 lower 105 strCtrl = "PwdPolicyLower"; 106 break; 107 case 4: 108 // at least 1 digit 109 strCtrl = "PwdPolicyDigit"; 110 break; 111 case 5: 112 // at least 1 special char 113 strCtrl = "PwdPolicySpecial"; 114 break; 115 } 116 if (strCtrl.length >= 0) { 117 if (bMatch) 118 toggleSegmentName(strCtrl, "PolicyChecked", bMatch); 119 else 120 toggleSegmentName(strCtrl, "PolicyNotChecked"); 121 } 122} 123function toggleSegmentName(strElement, strClassName, bMatch) { 124 document.getElementById(strElement).className = strClassName; 125 if (bMatch) 126 document.getElementById("symbol" + strElement).innerHTML = "✔ "; 127 else 128 document.getElementById("symbol" + strElement).innerHTML = "✘ "; 129} 130// } OX3609 131function ValidateNumber(objForm,strName,fMin,fMax,strErrMsg, fnOnError) { 132 var bResult=true; 133 var Value = objForm[strName].value.replace(/\s/gi, ""); 134 if ( Value.length > 0 ){ 135 Value = Value.replace( /,/gi, "." ); 136 Value = parseFloat(Value); 137 if (isNaN(Value) || (Value < fMin) || (Value > fMax)) { 138 bResult = false; 139 } 140 } 141 if ( !bResult ) { 142 if (fnOnError) fnOnError(objForm[strName]); 143 alert(strErrMsg); 144 try { 145 objForm[strName].focus(); 146 } catch (err) { } 147 } 148 return bResult; 149} 150function ValidateChars(objForm, strName, nMinLen, nMaxLen, strValidChars, strErrMsg, fnOnError) { 151 var bResult=true; 152 var strValue=objForm[strName].value; 153 var nLen = strValue.length ; 154 if ((nMinLen!=null)&&(nMinLen>0)) 155 if (nLen< nMinLen) bResult=false; 156 if ((nMaxLen!=null)&&(nMaxLen>0)) 157 if (nLen> nMaxLen) bResult=false; 158 if (bResult && (nLen>0)){ 159 for( var i = 0 ; (i < nLen) && bResult ; i++ ) 160 if ( strValidChars.indexOf(strValue.charAt(i)) < 0 ) bResult=false; 161 } 162 if ( !bResult ) { 163 if (fnOnError) fnOnError(objForm[strName]); 164 alert(strErrMsg); 165 try { 166 objForm[strName].focus(); 167 } catch (err) { } 168 } 169 return bResult; 170} 171function ValidateEditCtrl(objForm, strName, bRequired, nMaxLength, strRegExp, strErrMsg, fnOnError) { 172 var bResult = true; 173 var strValue = objForm[strName].value; 174 var TempVar = strValue.replace(/\s/gi,""); 175 if (!bRequired && (TempVar.length == 0)) bResult = true; 176 else{ 177 if (bRequired && (TempVar.length == 0)) bResult = false; 178 if (bResult && (nMaxLength != "") && (strValue.length > nMaxLength)) bResult = false; 179 if (bResult && (strRegExp != "") && (!strRegExp.test(strValue))) bResult = false; 180 } 181 if (!bResult){ 182 if (fnOnError) fnOnError(objForm[strName]); 183 alert(strErrMsg); 184 try { 185 objForm[strName].focus(); 186 } catch(err) { } 187 } 188 return bResult; 189} 190function ValidateEMailCtrl(objForm, strName, bRequired, nMaxLength, strErrMsg, fnOnError, strTarget) { 191 var bResult = true; 192 var strValue = objForm[strName].value; 193 if (strValue.length > 0){ 194 while(''+strValue.charAt(strValue.length-1) == ' ') strValue=strValue.substring(0,strValue.length-1); 195 while(''+strValue.charAt(0) == ' ') strValue = strValue.substr(1,strValue.length-1); 196 objForm[strName].value = strValue; 197 } 198 if (bRequired&&(strValue.length == 0)) bResult=false; 199 else if (strValue.length > nMaxLength) bResult=false; 200 else if (strValue.length > 0){ 201 while( ( strValue.length > 0) && (bResult)){ 202 var sEMail; var nIdx=strValue.indexOf(";"); 203 if (nIdx>-1){ 204 sEMail=strValue.substr(0,nIdx); 205 strValue=strValue.substr(nIdx+1); 206 } 207 else{ 208 sEMail=strValue; 209 strValue=""; 210 } 211 var nEMailLen=sEMail.length; 212 if (sEMail.indexOf("..") !== -1) { 213 bResult = false; 214 } 215 var nIdxAT=sEMail.indexOf("@"); 216 var nIdxDOT=sEMail.indexOf("."); 217 if (nEMailLen>0){ 218 var strValidEMailChars="@.-+_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 219 for(var i=0; (i< nEMailLen) && bResult;i++) 220 if ( strValidEMailChars.indexOf(sEMail.charAt(i)) < 0 ) bResult=false; 221 } 222 if ((bResult)&&(nIdxAT==-1 || nIdxAT==0 || nIdxAT==(nEMailLen-1))) bResult=false; 223 if ((bResult)&&(nIdxDOT==-1 || nIdxDOT==0 || nIdxDOT==(nEMailLen-1))) bResult=false; 224 if ((bResult)&&(sEMail.indexOf("@",(nIdxAT+1))!=-1)) bResult=false; 225 if ((bResult)&&(sEMail.substring(nIdxAT-1,nIdxAT)=="." || sEMail.substring(nIdxAT+1,nIdxAT+2)==".")) bResult=false; 226 if ((bResult)&&(sEMail.indexOf(".",(nIdxAT+2))==-1)) bResult=false; 227 if (bResult && (sEMail.substring(nEMailLen - 1, nEMailLen) === ".")) bResult = false; // . at end 228 } 229 } 230 if ( !bResult ) { 231 if (fnOnError) fnOnError(objForm[strName]); 232 if(strTarget) { 233 }else{ 234 alert(strErrMsg); 235 } 236 try { 237 objForm[strName].focus(); 238 } catch (err) { } 239 } 240 return bResult; 241} 242function ValidateDateTimeCtrl(objForm, strName,bRequired,bEnableTime,strErrMsg,fnOnError){ 243 var bResult=true; 244 var TempVar=/^\d{4}$/; 245 var nDay=objForm[strName+"D"].selectedIndex; 246 var nMonth=objForm[strName+"M"].selectedIndex -1; 247 var nYear=objForm[strName+"Y"].value.replace(/\s/gi,""); 248 if (!bRequired && ((nDay==0) && (nMonth==-1) && (nYear==""))) bResult=true; 249 else{ 250 if ((nDay==0) || (nMonth==-1) || (!TempVar.test(nYear))) bResult=false; 251 if (bResult && (nYear < 1800)) bResult=false; 252 if (bResult){ 253 var dtToCheck=new Date(nYear,nMonth,nDay); 254 if (dtToCheck.getMonth() != nMonth) bResult=false; 255 } 256 } 257 if (bEnableTime && bResult){ 258 var nHR=objForm[strName+"HR"].value.replace(/\s/gi,""); 259 var nMN=objForm[strName+"MN"].value.replace(/\s/gi,""); 260 if (!bRequired && ((nHR=="") && (nMN==""))) bResult=true; 261 else{ 262 if ((nHR=="") || (nMN=="")) bResult=false; 263 else{ 264 TempVar=/^\d{1,2}$/; 265 if ((!TempVar.test(nHR)) || (!TempVar.test(nMN))) bResult=false; 266 else if ((nHR>23) || (nMN>59)) bResult=false; 267 } 268 } 269 } 270 if (!bResult){ 271 if (fnOnError) fnOnError(objForm[strName + "D"]); 272 alert(strErrMsg); 273 try { 274 objForm[strName+"D"].focus(); 275 } catch (err) { } 276 } 277 return bResult; 278} 279function jsTrim( strString ) { return strString.replace(/^\s+|\s+$/g, ''); } 280function ValidateZipCode(objForm, strCtrlCountry, strCtrlZipCode, strMsg, fnOnError) { 281 var bResult = false 282 var nSelectedIdx, nSelectedValue, strCountryInfo, nCountryCode, nIdx, strZipCode ; 283 strCountryInfo = objForm[strCtrlCountry].value; 284 nIdx = strCountryInfo.indexOf( "]|[" ); 285 if ( nIdx >= 0 ) strCountryInfo = strCountryInfo.substr(0,nIdx); 286 nCountryCode = parseInt(strCountryInfo); 287 strZipCode = objForm[strCtrlZipCode].value; 288 //alert(strCountryInfo + ' | ' + strZipCode); 289 strZipCode = jsTrim( strZipCode ); 290 if ((nCountryCode == 66) || (nCountryCode == 214) || (nCountryCode == 215) || (nCountryCode == 221) || (nCountryCode == 222) || (nCountryCode == 223) || (nCountryCode == 224) || (nCountryCode == 225) || (nCountryCode == 226) || (nCountryCode == 227)) { 291 //if ( (strZipCode.length == 5) || (!isNaN(strZipCode)) ) bResult = true ; // 12.00 pass this test. 292 var objRegEx = new RegExp(/^([0-9]{5})$/); 293 if ( objRegEx.test(strZipCode) ) { 294 var strZipPrefix = strZipCode.substring(0, 2); 295 if ((strZipPrefix == '97') || (strZipPrefix == '98')) { 296 if (nCountryCode != 66) { 297 bResult = true; 298 } else {
299 if (strZipCode == '98000') bResult = true; // Monaco exception 300 } 301 } else { 302 if (nCountryCode == 66) bResult = true; 303 } 304 } 305 } else { 306 if (strZipCode.length > 0) bResult = true ; 307 } 308 if(!bResult){ 309 if (fnOnError) fnOnError(objForm[strCtrlZipCode]); 310 alert(strMsg); 311 try { 312 objForm[strCtrlZipCode].focus(); 313 } catch (err) { } 314 } 315 return bResult; 316} 317function ValidateMultiSelect(objForm, strName, strErrMsg, fnOnError) { 318 var bResult=true; 319 var TempVar=0; 320 var objOptions=objForm[strName].options; 321 for (var nIdx=0;nIdx< objOptions.length;nIdx++){ 322 if (objOptions[nIdx].selected) TempVar++; 323 } 324 if (TempVar==0){ 325 if (fnOnError) fnOnError(objForm[strName]); 326 alert(strErrMsg); 327 try { 328 objForm[strName].focus(); 329 } catch (err) { } 330 bResult = false; 331 } 332 return bResult; 333} 334function ValidateVATNumber(objForm, strName, strErrMsg, fnOnError) { 335 var bResult = true; 336 var CT_EEC_VATNUMBER_ROOT = "DE,AT,BE,DK,ES,FI,FR,EL,IE,IT,LU,NL,PT,GB,SE,CY,CZ,EE,HU,LT,LV,MT,PL,SI,SK"; 337 TempVar = objForm[strName].value; 338 TempVar = TempVar.replace( / /gi, "" ); 339 if ( TempVar.length > 0 ){ 340 bResult = false ; 341 if ( TempVar.length >= 10 ){ 342 var strCountry, strCountries = CT_EEC_VATNUMBER_ROOT; 343 strCountry = TempVar.substr( 0, 2 ); 344 strCountry = strCountry.toUpperCase() 345 if ( strCountries.indexOf(strCountry) >= 0 ) 346 bResult = true ; 347 } 348 } 349 if (!bResult) { 350 if (fnOnError) fnOnError(objForm[strName]) 351 alert(strErrMsg); 352 try { 353 objForm[strName].focus(); 354 } catch (err) { } 355 } 356 return bResult; 357}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.