1

I've been looking for an answer for this for a while now and wondering if anyone has had the same issue.

The jQuery.validation plugin works fine, normally, just there's a few URLs that it doesn't validate properly and I'm seriously struggling to figure out why (or a valid work-around).

Normal URLs work fine, such as http://www.play.com, but the following URL will always fail to validate:

http://www.play.com/DVD/Blu-ray/4-/21404340/Transformers-3-Dark-Of-The-Moon-3D/Product.html?searchstring=&searchtype=allproducts&searchsource=2&searchfilters=ae212{644651}%2bc{600}%2b&urlrefer=search

I'm guessing due to the { } characters.

I'm using the generic validation plugin usage:

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

Any insight into a fix for this would be very appreciated.

Chris Dixon
  • 9,147
  • 5
  • 36
  • 68

1 Answers1

0

Yes, those characters are invalid. One option you may wish to adopt is have an on change event on your URL input that replaces the current value with the URI encoded value.

$('.url-field').change(function() { $(this).val(encodeURI($(this).val())); });
Community
  • 1
  • 1
moribvndvs
  • 42,191
  • 11
  • 135
  • 149