如何为这些隐藏的字段提供所需和模式的验证。不适用于chrome。
ID NOM_N.PAYMENT_TYPE NUM_0.POWER_CONSUMPTION
Min. : 39 Min. :1.000 Min. : 0
1st Qu.:10053 1st Qu.:1.000 1st Qu.: 1304
Median :20409 Median :2.000 Median : 2170
Mean :19849 Mean :1.738 Mean : 2597
3rd Qu.:29781 3rd Qu.:2.000 3rd Qu.: 3452
Max. :38580 Max. :3.000 Max. :31062
NUM_0.HH_IM_HAUS NUM_0.GEWERBE_IM_HAUS ORD_R.REGIOTYP
1 :711 0 :1309 ?:136
2 :304 1 : 283 1: 22
? :136 ? : 136 2:156
3 :135 2 : 49 3:295
4 :125 3 : 16 4:363
5 : 97 4 : 3 5:263
(Other):293 (Other): 5 6:566
ORD_R.KAUFKRAFT ORD_R.STRTYP ORD_R.BEBAU ORD_P.STATUS
2 :373 ?: 136 ?:158 1 :250
3 :282 1:1000 1:999 2 :248
4 :263 2: 125 2:361 3 :229
1 :262 3: 349 3:246 4 :226
5 :204 4: 180 4: 30 5 :192
? :136 5: 11 5: 7 6 :148
(Other):281 (Other):508
ORD_P.BONITAET ORD_P.ANTDT ORD_P.ALTERSTR ORD_P.FAMILIEN
1 :338 9 :373 4 :594 7 :259
2 :289 8 :320 5 :534 6 :243
4 :198 7 :254 6 :232 5 :232
3 :195 6 :233 3 :213 8 :207
5 :170 5 :170 ? :136 4 :161
? :136 ? :136 2 : 48 2 :156
(Other):475 (Other):315 (Other): 44 (Other):543
ORD_P.PKW_DI ORD_P.PKW_LEIST ORD_P.KLBUS ORD_P.GEBRAUCHT
10 :454 1 :592 ?:374 6 :245
9 :269 2 :401 1:779 4 :223
8 :210 3 :252 2:436 5 :217
7 :158 4 :160 3:212 2 :215
6 :152 ? :136 3 :205
? :136 5 : 89 7 :192
(Other):422 (Other):171 (Other):504
ORD_P.GELAEND ORD_P.PSYCHONOMICS_1 ORD_P.PSYCHONOMICS_2
?:136 ?:388 ?:367
1:848 1:342 1:427
2:354 2:227 2:192
3:294 3:254 3:178
4:169 4:232 4:248
5:358 5:389
ORD_P.PSYCHONOMICS_3 ORD_P.PSYCHONOMICS_4
?:388 ?:386
1:154 1:293
2:276 2:263
3:282 3:256
4:368 4:282
5:333 5:321
ORD_P.PSYCHONOMICS_5 ORD_P.PSYCHONOMICS_6
?:367 ?:386
1:541 1:287
2:271 2:249
3:203 3:354
4:180 4:231
5:239 5:294
ORD_P.PSYCHONOMICS_7 ORD_P.PSYCHONOMICS_8 ORD_P.PHARM1
?:388 ?:388 7 :365
1:331 1:425 ? :343
2:277 2:355 6 :261
3:253 3:259 1 :216
4:298 4:195 5 :200
5:254 5:179 4 :159
(Other):257
ORD_P.PHARM2 ORD_P.PHARM3 ORD_P.PHARM4 ORD_P.PHARM5
1 :663 7 :566 ? :343 ? :343
2 :383 ? :343 1 :329 1 :329
? :343 1 :289 4 :311 2 :213
3 :147 6 :156 5 :300 6 :208
4 :106 3 :154 2 :201 5 :205
6 : 64 2 :115 3 :137 3 :201
(Other): 95 (Other):178 (Other):180 (Other):302
ORD_P.PHARM6 CLA_2.CANCELER
7 :534 1: 165
6 :427 2:1636
? :343
5 :176
4 : 97
3 : 81
(Other):143
用于上述html代码的jquery文件。
jquery的
<div class="form-group col-md-12" id="taxes">
<div class="form-group col-md-6 col-sm-6">
<label for="add_tax" class="control-label col-md-3">Tax Component</label>
<button id="b1" class="btn btn-info add_tax col-md-9 col-sm-12" type="button">Add</button>
<div class="template_tax col-md-offset-3">
<div class="controls" id="profs">
<div id="field_tax" class="form-group input-append col-md-12">
<select class="select form-control col-md-5" id="field1" name="tax1">
<option value="">select Tax</option>
<option value="project">project1</option>
</select>
<input autocomplete="off" class="input form-control col-md-5" id="field2" name="tax2" type="text" placeholder="tax %" data-items="8" pattern="\d+(\.\d*)||(\.\d*)?" title="(Must be a numeric or decimal value)" />
<button class="remove_tax btn btn-danger form-control col-md-2" type="button">X</button>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
如果您在html标签上提到验证(例如:http://www.w3schools.com/tags/att_input_pattern.asp)。答案是:你不应该。像这样的客户端验证仅仅是一个指导原则,攻击者可以轻松地绕过它们。由于隐藏了这些输入,因此普通用户无法找到它们。只需确保在服务器端验证!
如果你真的想这样做,你可以{i> {i}或类似的模式。
答案 1 :(得分:0)
将它写在脚本中,这是一种验证方式。你可以根据你的要求改变它
$("#field2").keydown(function (e) {
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A, Command+A
(e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
// let it happen, don't do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
答案 2 :(得分:0)
您需要<input type="submit"/>
元素中的<form>
元素才能触发验证。另外,只需将required="required"
添加到input
元素即可强制使用。
<form action="?" method="get">
<div class="form-group col-md-12" id="taxes">
<div class="form-group col-md-6 col-sm-6">
<label for="add_tax" class="control-label col-md-3">Tax Component</label>
<button id="b1" class="btn btn-info add_tax col-md-9 col-sm-12" type="button">Add</button>
<div class="template_tax col-md-offset-3">
<div class="controls" id="profs">
<div id="field_tax" class="form-group input-append col-md-12">
<select class="select form-control col-md-5" id="field1" name="tax1">
<option value="">select Tax</option>
<option value="project">project1</option>
</select>
<input autocomplete="off" required="required" class="input form-control col-md-5" id="field2" name="tax2" type="text" placeholder="tax %" data-items="8" pattern="\d+(\.\d*)||(\.\d*)?" title="(Must be a numeric or decimal value)" />
<button class="remove_tax btn btn-danger form-control col-md-2" type="button">X</button>
</div>
</div>
</div>
</div>
<input type="submit" />
</div>
</form>
<强>更新强>
要防止有关无效表单控件的Chrome错误,请从初始输入字段中删除required="required"
部分,然后使用javascript添加:
newItem.find("input").prop("required", "required"); // make it a mandatory field