1function SMValidateControls(){ 2var arrDeclarations = arguments[0], valid = true; 3 for(var i=0; i<arrDeclarations.length; i++){ 4 valid = arrDeclarations[i].isValid(); 5 if(!valid){ 6 return(false); 7 }; 8 }; 9 return(true); 10 }; 11 12function SMFormDataDeclaration(){ 13var $args = arguments, $t = this; 14 if($args.length>0){ 15 $t.init.apply($t, $args); 16 }; 17 }; 18 19SMFormDataDeclaration.prototype.init = function(){ 20var $args = arguments, $t = this, $m = ""; 21 $t.name = $args[0]; 22 $t.form = $args[1]; 23 $t.required = $args[2]; 24 $t.type = $args[3]; 25 $t.fixedValueOperator = $args[4]; 26 $t.fixedValue = $args[5]; 27 $t.validFrom = $args[6]; 28 $t.validTo = $args[7]; 29 $t.regularExpression = $args[8]; 30 $t.callExternalJS = $args[9]; 31 $t.errorMessages = new Array(); 32 // error messages 33 for(var i=10; i<$args.length; i++){ 34 $m = SX_uEsc($args[i]); 35 $t.errorMessages[i-10] = $m.replace(/\\n/g, "\n"); 36 }; 37 }; 38 39SMFormDataDeclaration.prototype.isValid = function(){ 40var $t = this, $form = document.forms[$t.form], $elem = null, $valid = true, 41 $oneSel = false, $val = null, $pat = null, $fV = null, 42 $em = $t.errorMessages; 43 if($form==null){ 44 return(false); 45 } 46 else $elem = $form.elements[$t.name]; 47 if($elem==null){ 48 return(false); 49 }; 50 // required: 51 if($t.required){ 52 switch($elem.type){ 53 case "checkbox": 54 $valid = $elem.checked; break; 55 case "select-one": 56 case "select-multiple": 57 for(var i=0; i<$elem.options.length; i++){ 58 if($elem.options[i].selected&&$elem.options[i].value!=""){ 59 $oneSel = true; 60 break; 61 }; 62 }; 63 $valid = $oneSel; break; 64 default: 65 $valid = ($elem.value!=""); break; 66 }; 67 if(!$valid){ 68 if($em[0]) alert($em[0]); 69 $elem.focus(); 70 return(false); 71 }; 72 }; 73 if($elem.type!="radio" && 74 $elem.type!="checkbox" && 75 $elem.type!="select-single" && 76 $elem.type!="select-multiple"){ 77 // type 78 if($t.type!=0){ 79 switch($t.type){ 80 case 1: 81 // text 82 $pat = new RegExp("^[a-z]*$", "gi"); break; 83 case 2: 84 // numeric 85 $pat = new RegExp("^\\d*$", "gi"); break; 86 case 3: 87 // email 88 $pat = new RegExp("^[\\w][\\w\\.\\-]+@[\\w\\.\\-]+\\.[a-z]+$", "gi"); break; 89 }; 90 $valid = $pat.test($elem.value); 91 if(!$valid){ 92 if($em[1]) alert($em[1]); 93 $elem.focus(); 94 return(false); 95 }; 96 }; 97 // fixed value 98 if($t.fixedValueOperator!=""){ 99 $val = $elem.value; 100 $fV = $t.fixedValue; 101 if($fV.indexOf("eval-js:")==0) $fV = eval($fV.substring(8)); 102 switch($t.fixedValueOperator){ 103 case "eq": 104 // equal 105 $valid = ($val==$fV); break; 106 case "neq": 107 // not equal 108 $valid = ($val!=$fV); break; 109 case "gt": 110 // greater than 111 $valid = (parseFloat($val) > parseFloat($fV)); break; 112 case "gte": 113 // greater or equal 114 $valid = (parseFloat($val) >= parseFloat($fV)); break; 115 case "lt": 116 // less than 117 $valid = (parseFloat($val) < parseFloat($fV)); break; 118 case "lte": 119 // less than or equal 120 $valid = (parseFloat($val) <= parseFloat($fV)); break; 121 }; 122 if(!$valid){ 123 if($em[2]) alert($em[2]); 124 $elem.focus(); 125 return(false); 126 }; 127 }; 128 // valid from / to 129 if($t.type!=3&&($t.validFrom!="0"||$t.validTo!="0")&&($t.validFrom!=""||$t.validTo!="")){ 130 $val = $elem.value; 131 if($t.type!=2) $val = $val.length; 132 if($t.validFrom!="0") $valid = ($val >= parseFloat($t.validFrom)); 133 if($t.validTo!="0") $valid = $valid && ($val <= parseFloat($t.validTo)); 134 if(!$valid){ 135 if($em[3]) alert($em[3]); 136 $elem.focus(); 137 return(false); 138 }; 139 }; 140 // regular expression 141 if($t.regularExpression!=""){ 142 $pat = new RegExp($t.regularExpression, "gi"); 143 // $elem.blur(); 144 $val = $elem.value; 145 $valid = $pat.test($val); 146 if(!$valid){ 147 if($em[4]) alert($em[4]); 148 $elem.focus(); 149 return(false); 150 }; 151 }; 152 }; 153 // external JS function 154 if($t.callExternalJS!=""){ 155 if(window[$t.callExternalJS]!=null){ 156 $val = $elem.value; 157 // extended for 5.5.7, added elem and form 158 $valid = window[$t.callExternalJS]($val, $elem, $form); 159 if(!$valid){ 160 if($em[5]) alert($em[5]); 161 $elem.focus(); 162 return(false); 163 }; 164 }; 165 }; 166 return(true); 167 };
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.