• 如何限制上传附件的格式?


    解决思路:1、在$(document).ready(function(){});中加上  $("#uploadFile").live("change",function () {};如下红色标记部分

    <script type="text/javascript">
            $(document).ready(function() {
                //$("#name").focus();
                var id=$("#id").val();
                if(id!=""){
                    $("#policeNo").attr("readonly","readonly")//
                }    
                $("#inputForm").validate({
                    submitHandler: function(form){
                        loading('正在提交,请稍等...');
                        form.submit();
                    },
                    errorContainer: "#messageBox",
                    errorPlacement: function(error, element) {
                        $("#messageBox").text("输入有误,请先更正。");
                        if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                            error.appendTo(element.parent().parent());
                        } else {
                            error.insertAfter(element);
                        }
                    }
                });            
                  $("#uploadFile").live("change",function () {
                        var filepath = $("input[name='uploadFile']").val();
                        var extStart = filepath.lastIndexOf(".");
                        var ext = filepath.substring(extStart, filepath.length).toUpperCase()
                        /* if(ext == "" or ext == null){
                            art.dialog.alert("请上传签字图片!");
                            return false;
                        } */
                        if( ext != "" && ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
                            art.dialog.alert("图片限于bmp,png,gif,jpeg,jpg格式,且大小不能超过10M");
                            $("#uploadFile").remove();
                            $("#pic_add").append("<input id='uploadFile' type='file' name='uploadFile'
     accept=".png,.jpg,.gif,.jpeg,.ico,.bmp"/>");
                            return false;
                        } 
                  });      
            });
        </script>

    2、页面加载完成后开始运行do stuff when DOM is ready 中的语句!

       $(document).ready(function() {

               // do stuff when DOM is ready

            });

    3、$("a").click(function(){});的用法

    $("a").click(function() {

            alert("Hello world!");

             });

           });

    $("div").click $("div")就是页面中所有的 div标签 这句话就是给所有的标签为div的元素 绑定了一个click事件 即当所有div 被鼠标单击的时候 执行 alert("Hello World!");

    live方法绑定的事件处理函数,在页面中未来添加的元素只要满足原来的选择器,仍然会导致事件触发。

  • 相关阅读:
    POJ 最小球覆盖 模拟退火
    POJ 1379 模拟退火
    PythonTip(2)
    PythonTip(1)
    LA 3353 最优巴士线路设计
    LA 4254 贪心
    判断分析
    因子分析——因子得分
    因子分析——应用
    因子分析——因子旋转
  • 原文地址:https://www.cnblogs.com/banxian-yi/p/5357480.html
Copyright © 2020-2023  润新知