joris

Function Cek URL

Jun 17th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. ============= Fungsi buat periksa Format URL
  2. function validUrl($url){
  3.         $format="/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/";
  4.         $url=strtolower($url);
  5.         if(preg_match($format,$url))
  6.         return true; else return false;
  7. }
  8.  
  9. ============= Pas dicek di form
  10. if(validUrl(document.telvistube.link.value)){
  11.     alert("Format Link Anda Salah. Contoh Format : http://www.youtube.com/QyZZikn");
  12.     form.link.focus();
  13.     return (false);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment