Browse Source

Merge pull request #604 from Arkni/master

fix the validation of the form in demo/tab.html and add some required messages in order to validate the demo/date.html.
Phuoc Nguyen 11 years ago
parent
commit
da2ec52f0e
2 changed files with 35 additions and 5 deletions
  1. 18 3
      demo/date.html
  2. 17 2
      demo/tab.html

+ 18 - 3
demo/date.html

@@ -11,9 +11,9 @@
     <script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
 
     <!-- Support datetime picker plugin: http://eonasdan.github.io/bootstrap-datetimepicker/ -->
-    <link rel="stylesheet" href="//eonasdan.github.io/bootstrap-datetimepicker/content/bootstrap-datetimepicker.css"/>
-    <script type="text/javascript" src="//eonasdan.github.io/bootstrap-datetimepicker/scripts/moment.js"></script>
-    <script type="text/javascript" src="//eonasdan.github.io/bootstrap-datetimepicker/scripts/bootstrap-datetimepicker.js"></script>
+    <link rel="stylesheet" href="http://eonasdan.github.io/bootstrap-datetimepicker/content/bootstrap-datetimepicker.css"/>
+    <script type="text/javascript" src="http://eonasdan.github.io/bootstrap-datetimepicker/scripts/moment.js"></script>
+    <script type="text/javascript" src="http://eonasdan.github.io/bootstrap-datetimepicker/scripts/bootstrap-datetimepicker.js"></script>
 
     <style type="text/css">
     /* Override to make the feedback icons shown properly */
@@ -110,6 +110,9 @@ $(document).ready(function() {
         fields: {
             monthDayYear: {
                 validators: {
+                    notEmpty: {
+                        message: 'The date is required and cannot be empty'
+                    },
                     date: {
                         format: 'MM/DD/YYYY'
                     }
@@ -117,6 +120,9 @@ $(document).ready(function() {
             },
             yearDayMonth: {
                 validators: {
+                    notEmpty: {
+                        message: 'The date is required and cannot be empty'
+                    },
                     date: {
                         format: 'YYYY-DD-MM'
                     }
@@ -124,6 +130,9 @@ $(document).ready(function() {
             },
             yearMonthDay: {
                 validators: {
+                    notEmpty: {
+                        message: 'The date is required and cannot be empty'
+                    },
                     date: {
                         format: 'YYYY.MM.DD',
                         separator: '.'
@@ -132,6 +141,9 @@ $(document).ready(function() {
             },
             monthDayYearTime: {
                 validators: {
+                    notEmpty: {
+                        message: 'The date is required and cannot be empty'
+                    },
                     date: {
                         format: 'MM/DD/YYYY h:m A'
                     }
@@ -139,6 +151,9 @@ $(document).ready(function() {
             },
             yearDayMonthTime: {
                 validators: {
+                    notEmpty: {
+                        message: 'The date is required and cannot be empty'
+                    },
                     date: {
                         format: 'YYYY-DD-MM h:m A'
                     }

+ 17 - 2
demo/tab.html

@@ -5,7 +5,7 @@
 
     <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
     <link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>
-    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" />
+    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" />
 
     <script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
     <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
@@ -114,6 +114,13 @@ $(document).ready(function() {
                         }
                     }
                 },
+                jobTitle: {
+                    validators: {
+                        notEmpty: {
+                            message: 'The company name is required'
+                        }
+                    }
+                },
                 address: {
                     validators: {
                         notEmpty: {
@@ -127,14 +134,22 @@ $(document).ready(function() {
                             message: 'The city is required'
                         }
                     }
+                },
+                country: {
+                    validators: {
+                        notEmpty: {
+                            message: 'The city is required'
+                        }
+                    }
                 }
             }
         })
         .on('status.field.bv', function(e, data) {
             var $form     = $(e.target),
-                validator = $form.data('bootstrapValidator'),
+                validator = data.bv,
                 $tabPane  = data.element.parents('.tab-pane'),
                 tabId     = $tabPane.attr('id');
+            
             if (tabId) {
                 var $icon = $('a[href="#' + tabId + '"][data-toggle="tab"]').parent().find('i');