Home > Backend Development > PHP Tutorial > Determine php file extension, _PHP tutorial

Determine php file extension, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 16:53:50
Original
744 people have browsed it

php file extension judgment,

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html" charset="utf-8">
    <title>check <span>file</span></title>
</head>
<body>
<b>文件扩展名验证</b>
<input type="text" name="int" value="文件.php" onblur="check(this)" id="int">
<input type="button" value="检测" onclick="check_value()">

<script>
    <span>function</span><span> check(obj){
        </span><span>if</span>(obj.value == "" || obj.value.length<3<span>){
            alert(</span>"输入的长度不能小于3且不能为空!"<span>);
            obj</span>.<span>focus();
        }
    }
    </span><span>function</span><span> check_value(){
        </span><span>var</span> str = $("int").<span>value;
        </span><span>var</span> repx = /\.(php|asp|jsp)$/<span>i;
        </span><span>var</span> type = str.substring(str.lastIndexOf("."),str.<span>length);
        </span><span>if</span>(type.match(repx) && str.lastIndexOf(".") != -1<span>){
            alert(</span>"文件扩展名正确"<span>);
            $(</span>"int").<span>focus();
        }</span><span>else</span><span>{
            alert(</span>"文件扩展名有误"<span>);
            $(</span>"int").<span>focus();
        }
    }
    </span><span>function</span><span> $(obj){
        </span><span>return</span> document.<span>getElementById(obj);
    }
</span></script>

</body>
</html>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1053798.htmlTechArticlephp file extension judgment, !DOCTYPEhtmlhead meta http-equiv="Content-type" content="text/html " charset="utf-8" titlecheck file /title/headbodyb file extension verification/binput type="t...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template