Jefferson Jefferson - 4 months ago 25x
jQuery Question

URL validation with jQuery validate plugin

I am using jQuery validation plugin URL validation for url validation. I ve added url:true to validate all valid URLs. The Validation plugin is great with the default functions it offers.

It accepts the urls started with http(s).

For example

It throws error when the URL is not started with http(s)

For example


$( "#myform" ).validate({
rules: {
field: {
required: true,
url: true

If the entered Url is not started with http(s), I want to add http(s) before validation. I don't want the URL to be validated with regular expressions. Because they are making lot of confusions. How can I add http/https before validation. If the entered URL is started with http(s) there is no problem.


There is no way to do this with the url rule. You would need to either:

  • Append http:// to the start of the URL field's value on blur if it wasn't already there
  • Use a custom Regex
  • Create a custom rule which does not require https?:// for the field to be considered valid