jQuery不能在页面上运行

时间:2010-01-29 17:42:43

标签: php jquery html

我有一个页面,允许用户从数据库编辑记录。简单。

html源代码如下:

<form id="prize_modify_form" enctype="multipart/form-data" action="" method="POST" accept-charset="utf-8"> 
   <p><label for="header">Header</label><input type="text" name="header" value="More Tvs!" id="header"></p> 
   <p><label for="description">Description</label><input type="text" name="description" value="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." id="description"></p> 
   <p><label for="short_description">Short Description</label><input type="text" name="short_description" value="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure d" id="short_description"></p> 
   <p><label for="expiration_date">Expiration Date</label><input type="text" name="expiration_date" value="0000-00-00" id="expiration_date"></p> 
   <p><label for="image">Image</label> 
         <a href="#" id="change_image_link">Change Image</a> 
      <input type="hidden" name="photo" value="png8.png" id="photo"> 
   </p> 
   <p><input type="submit" value="Save"></p> 
</form> 

<link rel="stylesheet" href="../../css/jquery-ui-1.7.2.custom.css" type="text/css" media="screen" title="no title" charset="utf-8"> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="../../js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="../../js/additional-methods.js" type="text/javascript" charset="utf-8"></script> 
<script type="text/javascript" charset="utf-8"> 
   $(document).ready(function(){
      alert('inside');

    // Set up the validations
    $('#prize_modify_form').validate({
        rules: {
            header: {
                required: true,
                minlength: 2
            },
            description: {
                required: true,
                minlength: 2
            },
            short_description: {
                required: true,
                minlength: 2,
                maxlengh: 250
            }
            image: {
                required: true,
                accept: "jpg|jpeg|gif|png"
            },
            expiration_date: {
                required: true,
                dateITA: true
            }
        }
    });
    // Add the date picker to expiration date
    $('#expiration_date').datepicker();

    // Redirect the page and create a popup for the change image link
    $('#change_image_link').click(function(){
        $id = $('#id').attr('value');
        $prize_id = $("#prize_id").attr('value');

        window.open("image.upload.php?id=" + $id,"Upload Image",
        "menubar=no,width=430,height=100,toolbar=no");
    });
   });
</script>

在我的jQuery代码中,没有任何东西可以运行。 最大的问题是这个页面几乎是另一个页面的复制粘贴...它完美地运行。 我不太清楚问题出在哪里。

1 个答案:

答案 0 :(得分:4)

这里至少有一个问题是缺少逗号:

            maxlengh: 250
        }
        image: {

应该是:

            maxlengh: 250
        },
        image: {