Need some help about removing www. - onclick

Discussion in 'JavaScript' started by deny, May 23, 2012.

  1. #1
    I need a bit help here. I have javascript function for removing white space and http(s)*: from input form.
    
    script type="text/javascript">
            function removeWhitespace() {
            var txtbox = document.getElementById('txtOne');
            txtbox.value = txtbox.value.replace(/\s/g, "");
            txtbox.value = txtbox.value.replace(/^http(s)*:\/\//i, "");
            }
        </script>
    
    Code (markup):
    Then inside input tag i have
    
     <input type="submit" value="" onclick="removeWhitespace()" />
    
    Code (markup):
    It works excellent but what i need now is also one extra line to remove also www. so that i can get get clean domainname.


    thanks
     
    Last edited: May 23, 2012
    deny, May 23, 2012 IP
  2. codersyard

    codersyard Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You may use
    txtbox.value = txtbox.value.replace(/www\./g, "");
     
    codersyard, May 25, 2012 IP