Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 16:34:27
Original
1502 people have browsed it

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.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template