Language Packages
New Features
addField() and removeField() methods for managing dynamic fields, thanks to @jcnmuliocontainer option for indicating the element showing all errorsgetInvalidFields() that returns all invalid fieldsdestroy() methodstatus.field.bv event which is triggered after updating the field status. It can be used to solve #300, #301isValidContainer(container) methodseparator option to the date validatorisValidField(field) methodsuccess.validator.bv and error.validator.bv events triggered after a validator completes$field instance to the callback validatorgroup optionrevalidateField(field) methodresetField(field, resetValue) methodupdateMessage(field, validator, message) methodChanges
submitHandler(). You can use new getSubmitButton() method to get the clicked submit buttonsetLiveMode() method$.fn.bootstrapValidator.helpers renames mod_11_10 to mod11And10, mod_37_36 to mod37And36submitHandler() option. Use success.form.bv event instead:v0.4.5 and earlier versions
$(form).bootstrapValidator({
submitHandler: function(form, validator, submitButton) {
...
}
});
v0.5.0
Using success.form.bv event:
$(form)
.bootstrapValidator(options)
.on('success.form.bv', function(e) {
// Prevent form submission
e.preventDefault();
var $form = $(e.target),
validator = $form.data('bootstrapValidator'),
submitButton = validator.getSubmitButton();
// Do whatever you want here ...
});
Improvements
updateStatus() method. The plugin now doesn't show the errors, feedback icons of given field if there are uncompleted validatorsinput-group, thanks to @tiagofontellaurl and method type (GET/POST), thanks to @ericnakagawaupdateOption() method for updating the particular validator option, thanks to @AlaskanShadeexcluded option or data-bv-excluded attributedata-bv-callback-callback attribute.input-group elementBug Fixes
has-error class, thanks to @alaversinclusive option in the between, greaterThan and lessThan validators, thanks to @johanronn77threshold option doesn't work on IE 8false if the country code is not supported_isExcluded() when initializing the form. This fixes #269, #273. Thanks to @AlaskanShadeDocument
Language Packages
$.fn.bootstrapValidator.helpers.date for validating a date, re-used in date, id, vat validatorsthreshold optionseparator option to the numeric validatorsubmitButtons to [type="submit"] to support input type="submit"$.fn.bootstrapValidator.helpers.mod_11_10 method that implements modulus 11, 10 (ISO 7064) algorithm. The helper is then reused in validating German and Croatian VAT numbers$.fn.bootstrapValidator.helpers.mod_37_36 method that implements modulus 37, 36 (ISO 7064) algorithm, used in GRid validatorname attribute and selector option for field$.fn.bootstrapValidator.helpers.luhn method that implements the Luhn algorithmselect elementexcluded: ':disabled' setting does not work on IE 8, thanks to @adgrafikexcluded optionname option, thanks to @jswaleenabled is set to false, thanks to @henningda{validatorname} and {validatoroption} must be lowercase, thanks to @tomByrervalidate() method from submit the form automatically. So we can call validate() to validate the formselector optionForm attributes:
<form
data-bv-message="This value is not valid"
data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
data-bv-feedbackicons-validating="glyphicon glyphicon-refresh"
>
Field attributes:
<input type="text" class="form-control" name="username"
data-bv-message="The username is not valid"
data-bv-notempty data-bv-notempty-message="The username is required and cannot be empty"
data-bv-stringlength="true" data-bv-stringlength-min="6" data-bv-stringlength-max="30" data-bv-stringlength-message="The username must be more than 6 and less than 30 characters long"
data-bv-different="true" data-bv-different-field="password" data-bv-different-message="The username and password cannot be the same as each other"
data-bv-remote="true" data-bv-remote-url="remote.php" data-bv-remote-message="The username is not available"
/>
| HTML 5 attribute | Validator |
|---|---|
min="..." |
greaterThan validator |
max="..." |
lessThan validator |
maxlength="..." |
stringLength validator |
pattern="..." |
regexp validator |
required |
notEmpty validator |
type="color" |
hexColor validator |
type="email" |
emailAddress validator |
type="range" |
between validator |
type="url" |
uri validator |
It's possible to use data-bv-trigger attribute:
<form data-bv-trigger="keyup">
<input type="text" class="form-control" name="firstName" placeholder="First name"
data-bv-trigger="keyup" />
...
<input type="text" class="form-control" name="lastName" placeholder="First name"
data-bv-trigger="blur" />
</form>
or trigger option:
$(form).bootstrapValidator({
trigger: 'blur', // Set for all fields
fields: {
firstName: {
trigger: 'keyup', // Custom for each field. Can be 'event1 event2 event3'
validators: {
...
}
},
lastName: {
trigger: 'blur',
validators: {
...
}
}
}
});
<div class="form-group">
<input class="form-control" type="text" name="surveyAnswer[]" />
</div>
<div class="form-group">
<input class="form-control" type="text" name="surveyAnswer[]" />
</div>
<div class="form-group">
<input class="form-control" type="text" name="surveyAnswer[]" />
</div>
setLiveMode() method to turn on/off the live validating modetype="hidden") and invisible element, thanks to @easonhan007disableSubmitButtons() is now marked as a public APIupdateStatus() method now accepts the field name onlysubmitHandler and the form is validfields.[fieldName].message option is not used when showing the error messageform.submit() inside submitHandlerselector option for each field. The field can be defined by CSS validator instead of the name attributecontainer option for each field to indicate where the error messages are shownupdateStatus() method to make the plugin play well with anotherenabled option and enableFieldValidators() method to enable/disable all validators to given fieldbower.json file, thanks to @ikanedocolumns option. Now the plugin works normally no matter how many columns the form usesresetForm method now only resets fields with validator rulessubmitHandler or default submission isn't called after remote validation completessubmitHandler() parameterresetForm() methodtruelive optionsubmitHandler optioncol-xs-), small (col-sm-), medium (col-md-) elementssubmitButtons option