===============================================================================
1.
1
|
<link href=
"<%=basePath %>bootstrap/css/bootstrap-datetimepicker.min.css"
rel=
"external nofollow"
rel=
"stylesheet"
media=
"screen"
>
|
===============================================================================
$(
function
(){
/* 文檔加載,執行一個函數*/
// $(".submit_review").attr({"disabled":"disabled"});
$(
'#defaultForm'
).bootstrapValidator({
message:
'This value is not valid'
,
feedbackIcons: {
/*輸入框不同狀態,顯示圖片的樣式*/
valid:
'glyphicon glyphicon-ok'
,
invalid:
'glyphicon glyphicon-remove'
,
validating:
'glyphicon glyphicon-refresh'
},
fields: {
/*驗證*/
company_name: {
/*鍵名username和input name值對應*/
validators: {
notEmpty: {
/*非空提示*/
message:
'公司名稱不能為空'
},
// stringLength: {/*長度提示*/
// min: 6,
// max: 30,
// message: '用戶名在6到30之間'
// }/*最后一個沒有逗號*/
}
},
company_id: {
validators: {
notEmpty: {
message:
'公司ID不能為空'
},
}
},
equipment_ip: {
validators: {
notEmpty: {
message:
'設備IP不能為空'
},
regexp: {
regexp: /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,
message:
'設備IP不合法'
}
}
},
}
})
});
===============================================================================
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
$(
"#btn_reset"
).click(
function
(event) {
/* Act on the event */
$(
'#defaultForm'
).data(
'bootstrapValidator'
).resetForm(
true
);
});
$(
"body"
).on(
'click'
,
'#btn_submit_add'
,
function
(event) {
/* Act on the event */
$(
'#defaultForm'
).bootstrapValidator(
'validate'
);
var
flag = $(
"#defaultForm"
).data(
'bootstrapValidator'
).isValid();
if
(!flag) {
toastr.error(
"填寫有誤,請重新填寫!"
);
}
else
{
$.post(
'addEquipmentInfoCheck.action'
, {
"equipmentInfoCheck.companyId"
: $(
"#company_id"
).val(),
"equipmentInfoCheck.companyName"
: $(
"#company_name"
).val(),
"equipmentInfoCheck.machineRoom"
: $(
"#computer_room"
).val(),
"equipmentInfoCheck.equipmentCabinet"
: $(
"#cabinet"
).val(),
"equipmentInfoCheck.deviceType"
: $(
"#equipment_type"
).val(),
"equipmentInfoCheck.deviceName"
: $(
"#equipment_name"
).val(),
"equipmentInfoCheck.deviceIp"
: $(
"#equipment_ip"
).val(),
"equipmentInfoCheck.deviceBrand"
: $(
"#equipment_brand"
).val(),
"equipmentInfoCheck.deviceModel"
: $(
"#equipment_model"
).val(),
"equipmentInfoCheck.position"
: $(
"#shelf_position"
).val(),
"equipmentInfoCheck.deviceSn"
: $(
"#equipment_sn"
).val(),
"equipmentInfoCheck.devicePn"
: $(
"#equipment_pn"
).val(),
"equipmentInfoCheck.state"
:1
},
function
(data, textStatus, xhr) {
/*optional stuff to do after success */
if
(textStatus ==
"success"
) {
// e.preventDefault();
$(
'#defaultForm'
).data(
'bootstrapValidator'
).resetForm(
true
);
$(
"#myModal_add"
).modal(
'hide'
);
toastr.success(
"提交成功"
);
}
else
{
$(
"#myModal_add"
).modal(
'hide'
);
toastr.error(
"提交失敗"
);
}
});
}
});
|