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

3
  • 1
    This answer has a very valid point, if you can avoid it, don't validate the url: stackoverflow.com/a/9961065/2712444 Commented Sep 20, 2013 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. stackoverflow.com/questions/2723140/… Commented Sep 20, 2013 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? jqueryvalidation.org/url-method Commented Sep 20, 2013 at 20:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.