jQuery Validation Plugin在IE中失败

时间:2014-04-16 05:39:46

标签: javascript jquery internet-explorer validation

我在Firefox和Chrome中有一个完美的工作页面。不幸的是,我需要支持IE。我正在使用jQuery v1.9.0和Validation v1.12.0

这是来源。

<!doctype html>
<html lang="en">  
<head>  
    <meta charset="utf-8">  
    <title>redacted</title>  
    <meta name="description" content="redacted">  
    <meta name="author" content="******">  
    <link rel="stylesheet" href="/styles.css">  
    <!--[if lt IE 9]>  
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>  
    <![endif]--> 
    <script src="/functionality/funcs.js" type="text/javascript"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
    <script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {
        $('div#spaces p').load('/reload.php/?id=<?php echo $id ?>').fadeIn("slow");
    }, 4000); // refresh every 10000 millisecond

</script>
<script src=http://ajax.aspnetcdn.com/ajax/jquery.validate/1.12.0/jquery.validate.js></script>
<script>
$(document).ready(function () {
$(function(){
    $("#bookingForm").validate({
        rules: {
            bookingname: "required",
            ticketno: "required",
            numPeople: {
                required: true,
                max: <?php echo $spaces ?>
            }
        },
        messages: {
            bookingname: "Please enter your name",
            ticketno: "Please enter the ticket number",
            numPeople: {
                required: "You are trying to book zero people",
                max: "The activity is full"
            }
        },

        submitHandler: function(form) {
            form.submit();
        }
    });
});
});
</script>





<body>
    <div class="header">
        <h1><?php echo $activity.": ".$day."-".$month."-".$year." ".$time;?></h1>
    </div>
    <div class="formInstructions">
    <p><a href='/index.php'>Home</a> <a href="/editEvent.php/?id=<?php echo $id;?>&day=<?php echo $day?>&month=<?php echo $month?>&year=<?php echo $year?>"> Edit Event </a></p>
    </div>
    <table class="eventInfo">
        <thead>
        <tr><th>Activity Name</th><th>Activity Date</th><th>Activity Time</th><th>Spaces</th><th>Cost</th><th>Venue</th></tr>
        </thead>
        <tr><td><?php echo $activity;?></td><td><?php echo $activity_date?></td><td><?php echo $time ?></td><td><div id="spaces"><p><?php get_spaces($id);?></p></div></td><td><?php get_cost($id)?></td><td><?php get_venue($id)?></td></tr>
    </table>
    <div class="formInstructions">
    <p><?php echo get_event_comments($id);?></p>
    </div>
    <!--table displays current bookings -->
    <table class="eventInfo">
    <thead>
    <tr><th>Ticket No.</th><th>Contact</th><th>Pickup</th><th>PAX</th><th>Comments</th></tr>
    </thead>
    <?php get_bookings($id)?>
    </table>

    <!--booking form --> 
    <form action="/formfuncs/bookingForm.php" method="POST" id="bookingForm" name="bookingform" novalidate="novalidate">
    <fieldset>
        <legend>Book an Activity</legend>
        <label for="bookingname">Name</label>
        <input type="text" name="bookingname" id="bookingname" />
        <label for="ticketno">Ticket No. </label>
        <input type="text" name="ticketno" id="ticketno" />
        <label for="pickup">Pick up</label>
        <input type="text" name="pickup" id="pickup" />
        <label for="numPeople">Number of People</label>
        <input type="text" id="numPeople" name="numPeople"/>
        <input type="hidden" id="id" value="<?php echo $id ?>" name="idfield"/>
        <label for="needsOrComments">Place comments here</label>
        <textarea name="needsOrComments" rows="10" cols="80">N/A</textarea>
        <input type="submit" value="Go" name="go">
    </fieldset>
    </form>

    </body>
    </html>

页面在Firefox和Chrome中加载,显示和交互时很好。当在Internet Explorer中加载时,控制台会吐出&#34; SCRIPT438:对象不支持属性或方法&#39;验证&#34;在第28行第5栏。

1 个答案:

答案 0 :(得分:0)

这可能是由于jquery和jquery validate之间的版本冲突造成的。确保使用与jquery兼容的jquery验证版本。