--- layout: default title: Setting validator options via HTML attributes permalink: /examples/attribute/ ---

Setting validator options via HTML attributes

Examples

{% include share.html %}

This example illustrates the ability of setting validator options via HTML attributes.

In order to set a specific validator to given field, you have to declare additional attributes for the field. For example:

{% highlight html %} {% endhighlight %}

Here are some important points when setting the attributes for field:

  1. validatorname and validatoroption must be lowercase.
  2. Use data-fv-validatorname, data-fv-validatorname="true", or data-fv-validatorname="data-fv-validatorname" to enable particular validator for field.
  3. Set data-fv-validatorname="false" to disable the validator
  4. There are some validators which not all options are configurable via HTML attribute. Refer to each validator documentation to see exactly the equivalent HTML attribute for each option.

If there are multiple elements having the same name, you just need to set the HTML attribute to one of them. For example:

{% highlight html %}
{% endhighlight %} {% include demo/tabs.html id="demo" frameworks="bootstrap" codes="declarative" %}