Posted By

multani on 05/14/08


Tagged

url javascript validation


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

somedirection
blackabee
joomla


URL validationin JavaScript


 / Published in: JavaScript
 

  1. function isValidURL(url){
  2. var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
  3. if(RegExp.test(url))
  4. return true;
  5. else
  6. return false;
  7. }

Report this snippet  

You need to login to post a comment.