首页 > Web开发 > 详细

php文件扩展名判断

时间:2015-09-12 10:47:37      阅读:252      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html" charset="utf-8">
    <title>check file</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>
    function check(obj){
        if(obj.value == "" || obj.value.length<3){
            alert("输入的长度不能小于3且不能为空!");
            obj.focus();
        }
    }
    function check_value(){
        var str = $("int").value;
        var repx = /\.(php|asp|jsp)$/i;
        var type = str.substring(str.lastIndexOf("."),str.length);
        if(type.match(repx) && str.lastIndexOf(".") != -1){
            alert("文件扩展名正确");
            $("int").focus();
        }else{
            alert("文件扩展名有误");
            $("int").focus();
        }
    }
    function $(obj){
        return document.getElementById(obj);
    }
</script>

</body>
</html>

技术分享

php文件扩展名判断

原文:http://www.cnblogs.com/myall/p/4802638.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!