Options
Option | HTML attribute | Type | Description |
---|---|---|---|
allowLocal | data-fv-uri-allowlocal | Boolean | Allow the private and local network IP. It is false , by default. |
message | data-fv-uri-message | String | The error message |
protocol | data-fv-uri-protocol | String | The protocols, separated by a comma. By default, it is set to http, https, ftp |
allowEmptyProtocol | data-fv-uri-allowemptyprotocol | Boolean | Allow the URI without protocol. Default to false |
When setting options via HTML attributes, remember to enable the validator by setting data-fv-uri="true".
You don't need to do that when using HTML 5 type="url" attribute.
You don't need to do that when using HTML 5 type="url" attribute.
The message and other options can be updated on the fly via the updateMessage() and updateOption() methods
Examples
Basic example
Thank to Mathias Bynens for providing this amazing collection of URL examples.
HTML 5 example
The following form uses HTML 5 type="url"
attribute to enable the uri validator.
Using with regexp validator
The following example is a combination usage of the uri and regexp validators.
It asks user to enter a valid URL which ends with .jpg, .jpeg, or .png.
Related validators
The following validators might be useful to you: