1

I am using "http://jqueryvalidation.org/" Jquery validator for validating my form.

In my form's URL field, a user can enter three types of URLs:-

1> http://192.16.19.65 - IP ADDRESS
2> http://application.com - ANY WEB URL
3> https://application.com - ANY SECURE WEB URL

Everything is working fine, but, Its working fine for Web URLs, but its not accepting the IP address.

Here is my code below:-

JQUERY

<script>
$().ready(function () {

    // validate signup form on keyup and submit
    $("#applicationUrlSetup").validate({
        rules: {
            ApplicationUrl: {
                required: true,
                url: true
            }
        },
        messages: {
        ApplicationUrl: {
            required: "Please enter your Application URL!",
            url: "Please enter a valid Application URL in, 'http://192.16.19.65',  'http://application.com' or 'https://application.com' format!",
        }
    }

    });
});

HTML

<p>
    <input id="ApplicationUrl" name="ApplicationUrl" type="text" />
</p>

Can you please suggest what can be done to make accept IP address too?

Let me know if you need any other info.

Thank You

UID
  • 4,434
  • 11
  • 45
  • 75
  • 1
    This answer has a very valid point, if you can avoid it, don't validate the url: http://stackoverflow.com/a/9961065/2712444 – Vlad Sep 20 '13 at 20:36
  • Or, you could look at this answer for the regex and modify it to handle ip addresses. Then use a custom function for the url rule. http://stackoverflow.com/questions/2723140/validating-url-with-jquery-without-the-validate-plugin – Vlad Sep 20 '13 at 20:45
  • 1
    I commented before I tried some code. Same on me. Looks like ip urls do work. Check the bottom of the page for an example input. So maybe you have an older version? http://jqueryvalidation.org/url-method – Vlad Sep 20 '13 at 20:54

0 Answers0