Validation

Any element who's value is obtainable through $el.val() can have simple validation rules assigned to them through the use of regular expressions.

When the value of the field matches the regular express the Bootstrap class is-valid is applied, when the value does not match the class is-invalid is applied.

The checking occurs on the jQuery events key-up and change

Give the template

<div>
    <input type='text' data-bind-validation="^[a-z A-Z]{0,}$">
</div>

The output would be

<div>
    <!-- valid input: "Indigo Montoya" -->
    <input type='text' class='is-valid' />

    <!-- invalid input: "S. Morgenstern" the period / full stop is invalid -->
    <input type='text' class='is-invalid' />

</div>

results matching ""

    No results matching ""