I need users to be able to create partial URLs without having to enter the full URL each time.
For example, let's say I plan the URL is www.example.com/areas/{userinput}/home . I want the user to be able to enter some text in the text box, and I want to check that he is a valid URL.
The URL authentication function is as follows:
url: function(value, element) { return this.optional(element) || /giantregex/.test(value); }
I tried to add a validation method to the validator using the following:
$.validator.addMethod("exturl", function(value) { return $.validator.methods.url.call($.validator, "http://www.example.com/areas/" + value + "/home"); });
However, when the form is validated and my extension is called, I keep getting this error:
Uncaught TypeError: Object function (d,a){this.settings=b.extend(true,{},b.validator.defaults,d);this.currentForm=a;this.init()} has no method 'optional'
optional looks like the method of the $.validator , but I cannot figure out how to call the validator url method.
jquery-validate
scottm
source share