garygreen / dominar

Lightweight bootstrap validator inspired by Laravel
http://garygreen.github.io/dominar/
22 stars 4 forks source link

Add includeValues option #20

Closed garygreen closed 8 years ago

garygreen commented 8 years ago

Will include the value from the given fields when passing onto the validator. Useful for "chained" type validation, and the confirmed rule.

<input name="latitude" type="hidden" value="56.384539">
<input name="latitude" type="hidden" value="56.384539">

<form>
    <div class="form-group">
        <label>Enter your location and select from dropdown menu.</label>
        <input name="location" type="text" value="London, UK">
    </div>
</form>
Dominar.Validator.register('geolocation', function() {
    return this.input.latitude.length && this.input.longitude.length;
}, 'Please enter a valid location.');

var dominar = new Dominar($('form'), {
    location: {
        rules: 'required|geolocation',
        includeValues: ['latitude', 'longitude']
    }
});