Home  >  Article  >  Web Front-end  >  Javascript verifies whether the URL address entered by the user is empty and the format is correct_javascript skills

Javascript verifies whether the URL address entered by the user is empty and the format is correct_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:34:271461browse

Copy code The code is as follows:



Copy code The code is as follows:

URL:








PHP detects URL address validity

The code is as follows

Copy code The code is as follows:

function is_url($str){
return preg_match("/^http://[A-Za-z0-9] .[A-Za-z0-9] [/=?%-&_~`@[]': !]*([^< ;>"])*$/", $str);
}
?>

If you want to try if it works normally, we can use the file_get_contents() function to verify it.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn