-3

I am creating a frontend form in WordPress where I am using a simple HTML textbox to input a web url. Now I want to check if the value entered is a URL and not just any random text. Anyway to do that?

  • how you know if you've written an url instead of text? – Marco Mura Dec 23 '14 at 16:24
  • Please use the search before asking a question. Also using some other search engines must not be bad, too: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=php%20verify%20url%20site%3astackoverflow.com - Next to that the concrete answer to your question: By writing the code for that. However this won't qualitfy as a question nor an answer fitting the Q&A format on Stackoverflow. The help center is of help: http://stackoverflow.com/help – hakre Dec 23 '14 at 16:33
  • Actually, I might have made a mistake with the duplicate question. But this one http://stackoverflow.com/questions/19463929/check-if-text-contains-url does contain what you need. – Funk Forty Niner Dec 23 '14 at 16:34
  • @Fred-ii-: The question isn't very clear either, so this can happen. I smell tons of duplicates, whatever a "web url" and a Wordpress textbox means for the OP. – hakre Dec 23 '14 at 16:36
  • @hakre Thanks; mistakes do happen from time to time ;-) *cheers* – Funk Forty Niner Dec 23 '14 at 16:38
  • Is http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url perhaps a better match for what is being asked here? – Jason Aller Dec 23 '14 at 16:59
  • Thanks a lot everyone. I tried searching and couldnt find anything previously but thanks a lot for pointing me to the correct link. I'll try it out. – Sandeep Tripathy Dec 23 '14 at 19:18

1 Answers1

-4
if (str[i] == 'w' && str[i+1] == 'w' && str[i+2] == 'w' && str[i+3] == '.')
return (1);
Taryn
  • 242,637
  • 56
  • 362
  • 405