Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I added below script to validate url in my form field. It shows valid url.Even if i use magento default class validate-url It won't show error.


  echo "invalid url";
   echo "valid url";

How to fix this issue.

share|improve this question
I am a bit confused as to what you are trying to achieve here. The url is valid from what I can see so both the validation.js and your regex will return that it is valid. What is the problem that you are looking to solve? – David Manners Jun 20 '14 at 7:00
this is invalid url. but it shows valid url.Is there any possibilities in the above method. – saravanavelu Jun 20 '14 at 7:03

The regex you have posted does not really do what you think it does. If you post this into a regex tool like:


Then you will be able to debug your regex, but basically what you have is a match for either http:// or www. so in your case is perfectly valid.

Magento's js/prototype/validation.js offers two different url validation options.

  1. validate-url - which requires either http:// https:// or ftp://
  2. validate-clean-url - which will work without the protocol,

So to make your regex work with the protocol you can use the following:


But be warned that this will also match http://a which I guess you do not want it to do.

share|improve this answer
ok.Thankyou.... – saravanavelu Jun 20 '14 at 7:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.