0

Good Afternoon All,

Been a bit since I had a question... Guess my education from Daniweb is paying off...;-))

I have a form where a member is posting a banner URL and alt text to display a banner on our site.

I would like to validate the URL they enter as being formatted correctly.

I don't want them to enter the http:// because I will prepend that in the link display.

this is what I have...

    if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$clean_banner_link)){
      $link_error = 'Link URL is NOT in a valid Format!';
      $disp_mess = 'Please Correct Highlighted fields!';
    }

But this allows the entry of http https ftp
OR requires that it begin with a www.

in the case where someone has a URL that is a sub-domain, they would be using that sub-domain handle as opposed to the www

So, the question is... How can I Refuse anything:// and at the same time allow either the www. or sub-domain. and validate the balance of the input?

OR even not require anything in that space, so they could enter SITEURL.com and have it accepted because when I prepend the http:// it will be http://SITEURL.com

Is it possible to format the validation to do all of this at once?

Thanks in advance.
Douglas

1
Contributor
1
Reply
10
Views
2 Years
Discussion Span
Last Post by showman13
0

Forget I asked... it just dawned on me that I got a similar answer on the previous question a couple weeks ago...

Not sure whether I need to do any validation on the url actually

I can use the type="url" and let them have at it.

I clean the entry when submitted anyway, so I believe that will take care of it.

I'm going to leave this open just in case anyone wants to point out to me that I am Wrong... LOL. It has happened before.

thanks, and sorry for the unnecessary question.

Douglas

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.