Browse Source

#661: Add headers option to the remote validator, thanks to @ryan2049

Phuoc Nguyen 11 years ago
parent
commit
54b05a41b6

+ 1 - 0
CHANGELOG.md

@@ -22,6 +22,7 @@ __Improvements__
 * [#549](https://github.com/nghuuphuoc/bootstrapvalidator/pull/549), [#600](https://github.com/nghuuphuoc/bootstrapvalidator/pull/600): Change the CSS/JS path in ```demo/remote.html``` and ```demo/message.html```, thanks to [@leegtang](https://github.com/leegtang), [@Arkni](https://github.com/Arkni)
 * [#604](https://github.com/nghuuphuoc/bootstrapvalidator/pull/604): Fix the ```demo/date.html``` and ```demo/tab.html``` examples, thanks to [@Arkni](https://github.com/Arkni)
 * [#609](https://github.com/nghuuphuoc/bootstrapvalidator/pull/609): Add content-type header for ```demo/remote.php```, thanks to [@etorres](https://github.com/etorres)
+* [#661](https://github.com/nghuuphuoc/bootstrapvalidator/pull/661): Add ```headers``` option to the [remote](http://bootstrapvalidator.com/validators/remote/) validator, thanks to [@ryan2049](https://github.com/ryan2049)
 
 __Bug Fixes__
 

+ 1 - 0
CONTRIBUTORS.md

@@ -54,6 +54,7 @@ I would like to give big thanks to the following contributors:
 * [@phillprice](https://github.com/phillprice)
 * [@pRieStaKos](https://github.com/pRieStaKos)
 * [@roryprimrose](https://github.com/roryprimrose)
+* [@ryan2049](https://github.com/ryan2049)
 * [@smeagol74](https://github.com/smeagol74)
 * [@thisisclement](https://github.com/thisisclement)
 * [@tiagofontella](https://github.com/tiagofontella)

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.1-dev, built on 2014-08-11 10:00:10 PM
+ * @version     v0.5.1-dev, built on 2014-08-14 8:29:24 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 8 - 5
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.1-dev, built on 2014-08-11 10:00:10 PM
+ * @version     v0.5.1-dev, built on 2014-08-14 8:29:24 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -4724,6 +4724,7 @@
          *  }
          * - name {String} [optional]: Override the field name for the request.
          * - message: The invalid message
+         * - headers: Additional headers
          * @returns {Boolean|Deferred}
          */
         validate: function(validator, $field, options) {
@@ -4732,10 +4733,11 @@
                 return true;
             }
 
-            var name = $field.attr('data-bv-field'),
-                data = options.data || {},
-                url  = options.url,
-                type = options.type || 'POST';
+            var name    = $field.attr('data-bv-field'),
+                data    = options.data || {},
+                url     = options.url,
+                type    = options.type || 'POST',
+                headers = options.headers || {};
 
             // Support dynamic data
             if ('function' === typeof data) {
@@ -4752,6 +4754,7 @@
             var dfd = new $.Deferred();
             var xhr = $.ajax({
                 type: type,
+                headers: headers,
                 url: url,
                 dataType: 'json',
                 data: data

File diff suppressed because it is too large
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 5 - 4
src/js/validator/remote.js

@@ -24,6 +24,7 @@
          *  }
          * - name {String} [optional]: Override the field name for the request.
          * - message: The invalid message
+         * - headers: Additional headers
          * @returns {Boolean|Deferred}
          */
         validate: function(validator, $field, options) {
@@ -32,10 +33,10 @@
                 return true;
             }
 
-            var name = $field.attr('data-bv-field'),
-                data = options.data || {},
-                url  = options.url,
-                type = options.type || 'POST',
+            var name    = $field.attr('data-bv-field'),
+                data    = options.data || {},
+                url     = options.url,
+                type    = options.type || 'POST',
                 headers = options.headers || {};
 
             // Support dynamic data