Validate URL using Java Script

Validate URL using Java Script

/*   Java Script code-----------------------------
--------------------------------------------------------------------------------------------------
function isUrl(urlByUser) {   
       var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
       return regexp.test(urlByUser);
  }

// Here "FieldName" is the id of HTML element in your html form
if((isUrl(document.getElementById("FieldName").value))){    
  alert(''Valid URL");                                                              
   return true;       
              
         }
else{
 alert(''Sorry, invalid walk URL.  Please enter URL starts with http:// or www.");
   return false;
}
--------------------------------------------------------------------------------------------------
*/

Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine

Session timeout interceptor in struts 2