Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:50:33+00:00 2026-06-06T23:50:33+00:00

Below is the code snippet where I have written the code to have the

  • 0

Below is the code snippet where I have written the code to have the IP address masked and validate it using jQuery. But, I am getting error message for valid IP addresses (like 222.222.222.222). Can someone please help?

            //Validate the form
            $('#form').validate({
                rules: {
                    ip: {
                        required: true,
                        IP4Checker: true
                    },
                    subnet: {
                        required: true,
                        IP4Checker: true
                    },
                    gateway: {
                        required: true,
                        IP4Checker: true
                    },
                    dns1: {
                        required: true,
                        IP4Checker: true
                    },
                    dns2: {
                        required: true,
                        IP4Checker: true
                    }
                },
                messages: {
                    ip: "Please enter a valid IP Address",
                    subnet: "Please enter a valid Subnet Mask Address",
                    gateway: "Please enter a valid Gateway Address",
                    dns1: "Please enter a valid DNS1 Address",
                    dns2: "Please enter a valid DNS2 Address"
                }
            });

            //Validate the IP addresses
            $(function() {
                $.validator.addMethod('IP4Checker', function(value) {
                    var ip = "^(?:(?:25[0-5]2[0-4][0-9][01]?[0-9][0-9]?)\\.){3}" +
                        "(?:25[0-5]2[0-4][0-9][01]?[0-9][0-9]?)$";
                    return value.match(ip);
                });
            });

            //Set mask for IP address fields
            $(".ip").mask("999 . 999 . 999 . 999");

            //Store numbers in hidden field
            $(".ip").blur(function () {

                //Create char array from phone number field
                var charArray = $(this).val().split("");

                var num = "";

                //taking the input
                $.each(charArray, function(index, value) {
                    num = num + value;
                });
            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:50:35+00:00Added an answer on June 6, 2026 at 11:50 pm

    You regex is missing its | characters ie.

    \b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
    

    Also note you could shorten this to

    \b(?:\d{1,3}\.){3}\d{1,3}\b
    

    If you dont need to check it is a valid ip address between 0-255

    also any \ needs to be escaped itself so it will be \

    reference

    UPDATE

    OP showed fiddle and hadnt read above line also mask had spaces either side of the . so the regex was never valid as the mask added the spaces.

    fixed Fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small snippet of code below that I'm running using PellesC .
I have the code snippet below in C++ which basically calculates the pi using
i have below code snippet. It throws the exception at line 3 but query
i have below code snippet. I am not getting how to change the color
I have code snippet below I would like to add error checking Like If
I have written some code using jQuery to use Ajax to get data from
Regarding the below code snippet i understand the bit but i have few confusion
I have the below code snippet, which runs fine. But the problem is it
I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10
I have this snippet of code below. I want to pass the value of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.