1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how can i get this Url validate code to work properly

Discussion in 'Blogging' started by Bestcreaters, Nov 8, 2016.

  1. Bestcreaters

    Bestcreaters Power Member

    Joined:
    Jul 10, 2013
    Messages:
    618
    Likes Received:
    270
    Occupation:
    money maker
    Location:
    Making Money is important
    by defult if customers try to sell there products on site it says they need to verify there homepage but must of the time people add eg: http:www.ebay.com/myshop the site wont allow them to list till they remove /myshop it only allows http:www.ebay.com how can i fix it below to allow them to add /myshop etc below is urlcheck.js file can anyone please advised


    Code:
    // JavaScript Document
    function urlcheck(str){
        var url="http://"
        var dot="."
        var lurl=str.indexOf(url)
        var ldot=str.indexOf(dot)   
        var lstr=str.length
        var j=0
    
        if (str.indexOf(url)==-1 || str.indexOf(url)>0){
           alert("Invalid URL. Please provide http://")
           return false
        }
        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
                alert("Invalid URL")
                return false
        }
        if(str.indexOf(url,(lurl+1)) != -1){
            alert("Invalid URL")
            return false
        }
        if (str.substring(7,8)==dot || str.substring(lurl+8,lurl+9)==dot){
                alert("Invalid URL")
                return false
        }
        if (str.indexOf(dot,(lurl+2))==-1){
            alert("Invalid URL")
            return false
        }
        
        for(var i=lstr-1; i >= 0; i--){
            j++
            if(str.substr(i,1)==dot){
                break;
            }       
        }
        
        if(j>5 || j<3){
            alert("homepage Must not have / ")
            return false
        }
        if (str.indexOf(" ")!=-1){
            alert("Invalid URL")
            return false
        }
    
         return true
    }
    
     
  2. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,064
    Likes Received:
    10,836
    Occupation:
    WHEREZ MA
    Location:
    BITCOINS AT?
    Home Page:
    You can't verify a site in a /subdirectory - because that does not prove you have access to the root.

    Thus you must add a file to / in order to prove your ownership.
     
    • Thanks Thanks x 1