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;
}
--------------------------------------------------------------------------------------------------
*/

Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI