How does javascript determine if the input url is correct

  • 2020-03-30 02:35:45
  • OfStack

Web pages come, the original web advertising too much, affect the mood
 
<html> 
<head> 
<title> Check for URL</title> 
<script language="javascript"> 
function check(){ 
str = form1.txt.value; 
str = str.match(/http://.+/); 
if (str == null){ 
alert(' You enter the URL invalid '); 
return false; 
}else{ 
alert(" You enter the URL effective "); 
return true; 
} 
} 
</script> 


</head> 
<body> 
<form name="form1" onSubmit="return check()"> 
<input type="text" name="txt"> 
<input type="submit" value=" inspection "> 
</form> 
</body> 
</html> 

Related articles: