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);
}
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;
}
alert(''Valid URL");
return true;
}
else{
alert(''Sorry, invalid walk URL. Please enter URL starts with http:// or www.");
return false;
return false;
}
--------------------------------------------------------------------------------------------------
*/
Comments
Post a Comment