onsubmit rewrite?

Discussion in 'HTML & Website Design' started by BusinessMachine, Jun 3, 2013.

  1. #1
    Hey everyone,

    I am currently setting up WHMCS and I'm working on the domain checker. The input on the form accepts URL's without "www." so will it be possible to use either javascript or php for example to remove this on submit?

    So for example a visitor enters "www.domainexample.com", clicks "Check Availability" and the form removes the "www." and posts just "domainexample.com".

    I usually get things done without having to ask questions and can usually find answers to things using Google but I already did some looking around and can't find anything on this.

    Regards,
    Shane
     
    Solved! View solution.
    BusinessMachine, Jun 3, 2013 IP
  2. #2
    Hi,

    It is very much possible.
    Define a javascript function to get the index of . and then replace the substring till that index with null.
    var url="www.abc.com";
    var temp = url.substr(url.indexOf('.')+1);
    var domain = url.replace(temp,"");
    Code (markup):
    Hope it answers your question.
    Thanks
     
    Arun@m6, Jun 4, 2013 IP
  3. Andre Glegg

    Andre Glegg Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Modify this and place this above the code that handles the form data.
    $domain = parse_url('http://www.google.com', PHP_URL_HOST);
    $domain = preg_replace('/^(www\.)/i', '', $domain);
    Code (markup):
    it will remove (http:://, www and trailing slash)
     
    Andre Glegg, Jun 4, 2013 IP