/    Sign up×
Community /Pin to ProfileBookmark

Validation for domain name & IPAddress

Hi
Can any one please tell how to validate for domain name ([url]www.somename.com[/url]) and IP Address (111.333.99.34)

Conditions for IP Address is

  • 1.

    only four “.” are allowed & is a must


  • 2.

    numbers should not cross 255


  • 3.

    no other charecters other than “.” is allowed

    shara

  • to post a comment
    JavaScript

    7 Comments(s)

    Copy linkTweet thisAlerts:
    @CharlesOct 22.2003 — [font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

    "http://www.w3.org/TR/html4/strict.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <meta name="Content-Script-Type" content="text/javascript">

    <title>Example</title>

    <style type="text/css">

    <!--

    label {display:block; margin:1em 0em}

    input {display:block}

    -->

    </style>

    <script type="text/javascript">

    <!--

    String.prototype.isIPAddress = function () {if (!this.match(/^(d+).(d+).(d+).(d+)$/)) return false; for (var i=1; i<=4; i++) {if (RegExp['$' + i] > 255) return false}; return true}

    // -->

    </script>

    <form action="">

    <div>

    <label>IP Address<input type="text" onchange="if (!this.value.isIPAddress()) {alert('That does not appear to be a valid IP Address.'); this.value=''; this.focus()}"></label>

    <button type="submit">Submit</button>

    </div>

    </form>[/font]
    Copy linkTweet thisAlerts:
    @shanuraguauthorOct 23.2003 — Thanks Charles

    But how to validate Domain name ie www.wesitename.com

    shara
    Copy linkTweet thisAlerts:
    @CharlesOct 23.2003 — [font=georgia]If you can tell me what constitutes a valid domain name then I can write your script.[/font]
    Copy linkTweet thisAlerts:
    @shanuraguauthorOct 23.2003 — It is nothing but any web site address, it should be in

    www.websitename.com (com/co/org...) format

    shara
    Copy linkTweet thisAlerts:
    @CharlesOct 23.2003 — [i]Originally posted by shanuragu [/i]

    [B]It is nothing but any web site address, it should be in

    www.websitename.com (com/co/org...) format



    shara [/B]
    [/QUOTE]
    [font=georgia]We need a lot more to go on than that. What characters are allowed? What are the length restrictions? What about case? Do you want to require the tripple w? What about the country codes?[/font]
    Copy linkTweet thisAlerts:
    @shanuraguauthorOct 23.2003 — Sorry!!

    here are the conditions :

    format is www.sitename.com

  • 1. two "." are must

  • 2. www is a must

  • 3. last word should always be more than one letter (co,com...) & only charecters

  • 4. Website name can be alphanumeric, no limit for wesite name length
  • 5. It should start with www only



  • shara
    Copy linkTweet thisAlerts:
    @AdamGundryOct 23.2003 — I think this should do it:

    String.prototype.isDomainName = function () {return this.match(/^www.w{2,}.[a-zA-Z]{2,}$/)}

    Adam
    ×

    Success!

    Help @shanuragu spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...