English 中文(简体)
jQuery Validate Framework + qTip not firing on submit
原标题:

Hereunder, I m trying to use jQuery Validate Framework with qTip 2.0.

This is working in Chrome but not in IE9, any ideas?

<html>
<head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" 
     type="text/javascript"></script>
  <script src="jquery.qtip.min.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="jquery.qtip.min.css"/>
  <script type="text/javascript" 
     src="http://jquery.bassistance.de/validate/jquery.validate.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {

var myForm = $( form:first );

   myForm.validate({
         errorClass: "errormessage",
         onkeyup: false,
         errorClass:  error ,
         validClass:  valid ,
         rules: {
            fullname: { required: true, minlength: 3 },
            email: { required: true, email: true }
         },
         errorPlacement: function(error, element)
         {
            // Set positioning based on the elements position in the form
            var elem = $(element),
               corners = [ left center ,  right center ],
               flipIt = elem.parents( span.right ).length > 0;

            // Check we have a valid error message
            if(!error.is( :empty )) {
               // Apply the tooltip only if it isn t valid
               elem.filter( :not(.valid) ).qtip({
                  overwrite: false,
                  content: error,
                  position: {
                     my: corners[ flipIt ? 0 : 1 ],
                     at: corners[ flipIt ? 1 : 0 ],
                     viewport: $(window)
                  },
                  show: {
                     event: false,
                     ready: true
                  },
                  hide: false,
                  style: {
                     classes:  ui-tooltip-red ui-tooltip-rounded  // Make it red... the classic error colour!
                  }
               })

               // If we have a tooltip on this element already, just update its content
               .qtip( option ,  content.text , error);
            }

            // If the error is empty, remove the qTip
            else { elem.qtip( destroy ); }
         },
         success: $.noop, // Odd workaround for errorPlacement not firing!
   });
});

</script>
<form id="MyForm" autocomplete="off" method="post">
   <input id="Field1" name="fullname" 
          type="text" 
          value="" maxlength="20" />
   <br/>
   <input id="Field2" name="email" 
          type="text" 
          value="" maxlength="255" />
   <br/>
   <input type="submit" value="Submit order" />
</form>
</body>
</html>
问题回答

The last element in your array/object ends in a trailing comma, IE will not like this but other browsers are OK with it.

 success: $.noop    // removed comma




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签