فهرست منبع

添加启动作业实现表单校验功能

James Iter 8 سال پیش
والد
کامیت
af4ec11b60
3فایلهای تغییر یافته به همراه28 افزوده شده و 2 حذف شده
  1. 1 0
      templates/disk_create.html
  2. 26 2
      templates/guest_boot_jobs.html
  3. 1 0
      templates/guest_create.html

+ 1 - 0
templates/disk_create.html

@@ -53,6 +53,7 @@
             // Since the Bootstrap Button hides the radio and checkbox
             // We exclude the disabled elements only
             excluded: ':disabled',
+            locale: 'zh_CN',
             fields: {
                 size: {
                     validators: {

+ 26 - 2
templates/guest_boot_jobs.html

@@ -63,6 +63,30 @@
         $('#add_boot_job_modal').on('show.bs.modal', function (me) {
             refresh_boot_job_selectpicker($('#boot_job_selector'));
         });
+        $('#add_guest_boot_job_form').formValidation({
+            framework: 'bootstrap4',
+            icon: {
+                valid: 'fa fa-check',
+                invalid: 'fa fa-times',
+                validating: 'fa fa-refresh'
+            },
+            // Since the Bootstrap Button hides the radio and checkbox
+            // We exclude the disabled elements only
+            excluded: ':disabled',
+            locale: 'zh_CN',
+            fields: {
+                boot_job_selector: {
+                    validators: {
+                        notEmpty: {}
+                    }
+                }
+            }
+        })
+        .on('success.field.fv', function(e, data) {
+            if (data.fv.getInvalidFields().length > 0) {    // There is invalid field
+                data.fv.disableSubmitButtons(true);
+            }
+        });
     });
 
     function refresh() {
@@ -258,7 +282,7 @@
             </div>
             <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
                 <div class="example-box-wrapper">
-                    <form class="form-horizontal bordered-row">
+                    <form id="add_guest_boot_job_form" class="form-horizontal bordered-row">
                         <div class="form-group">
                             <div class="col-sm-2"></div>
                             <label class="col-sm-2 control-label"><span class="glyph-icon icon-list-alt"></span>&nbsp;&nbsp;启动作业</label>
@@ -270,7 +294,7 @@
                         <div class="form-group">
                             <div class="col-sm-4"></div>
                             <div class="col-sm-6 pull-right">
-                                <button class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" onclick="add_boot_job_at();">添加</button>
+                                <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" onclick="add_boot_job_at();" disabled>添加</button>
                                 <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
                             </div>
                         </div>

+ 1 - 0
templates/guest_create.html

@@ -52,6 +52,7 @@
             // Since the Bootstrap Button hides the radio and checkbox
             // We exclude the disabled elements only
             excluded: ':disabled',
+            locale: 'zh_CN',
             fields: {
                 ability: {
                     validators: {