2013-11-14 30 views
0

一切似乎都被正確引用,但我無法讓它正常工作。奇怪的是,它曾經工作過一次,但在彈出驗證消息前花了10秒鐘,沒有改變任何東西,並再次嘗試,但停止工作。我唯一的警告是在jQuery庫中的event.returnValue is deprecated. Please use the standard event.preventDefault() instead.jQuery.validationEngine引用錯誤?

<html> 

<head> 
<link rel="stylesheet" href="jQuery-Validation-Engine-master/css/validationEngine.jquery.css" type="text/css"/> 
    </head> 

<body> 

    <form id="formID"> 
     <input class="validate[required]" type="text" id="agree" name="agree"/> 
    </form> 

<script src='js/jquery-1.10.2.min.js'></script> 
    <script src="jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script> 
    <script src="jQuery-Validation-Engine-master/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script> 

    <script> 
     $(document).ready(function(){ 
      $("#formID").validationEngine(); 
     }); 
    </script> 

</body> 

如果有什麼不對上述那麼它可能是其他人在我的項目干擾的東西,但任何幫助,將不勝感激。

+1

檢查[jQuery的錯誤#14320](http://bugs.jquery.com/ticket/14320)。似乎應該在未來的版本中修復它。 Chrome和Firefox遭遇同樣的問題。 – inhan

+0

@inhan好的,謝謝 – user1

+0

使用jQuery lib 1.11.0擺脫了警告,但仍然無法正常工作。 – user1

回答

0

在我上面提到的情況下,更新到jQuery lib 1.11.0爲我擺脫了警告。 (最新的Chrome)

這裏是我結束了使用validationEngine如果有興趣:

<form id="formID" /> 
<button type="submit" value="Save" id="Save" onclick="clicked(event);">Submit Survey</button> 

function clicked (e) 
    { 
     if (confirm('Are you sure you want to submit?')) 
     { 
      if ($("#formID").validationEngine('validate')) 
      { 
       my.LocalStorage.save(); 
      } 
     } 
     e.preventDefault(); 
    } 
0

發生了什麼,可能是在jQuery加載時,你的插件尚未加載,所以當你調用validationEngine()方法時,它還沒有定義。我建議與Modernizr同步加載腳本,並在腳本加載完成後調用該方法。

如果您堅持使用Modernizr方式,您只需將最小化的Modernizr版本包含在頭部並調用您的腳本,如下所示。

<!doctype html> 
<html> 
    <head> 
     <meta charset="UTF-8"> 
     <title>Your Document</title> 
     <!-- 
      following script loads first. nevermind the version, I copied it from a script of mine 
     --> 
     <script type="text/javascript" src="js/modernizr.2.6.2.min.js"></script> 
    </head> 

    <body> 
     <form id="formID"> 
      <!-- etc --> 
     </form> 
     <script type="text/javascript"> 
      Modernizr.load([ 
      { 
       // following loads next 
       load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', 
       complete: function() { 
        if (!window.jQuery) Modernizr.load('js/jquery-1.10.2.min.js'); 
        // this is your local copy of jQuery, in case you might need a fallback 
       } 
      },{ 
       // finally the remaining scripts load 
       load:[ 
        'jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js', 
        'jQuery-Validation-Engine-master/js/jquery.validationEngine.js' 
       ], 
       complete: function() { 
        // all is loaded. do what you want here. 
        $("#formID").validationEngine(); 
       } 
      }]); 
     </script> 
    </body> 
</html> 
+0

但是沒有得到解決這個問題,但是這個工作:http://jsfiddle.net/8q4cU/ – user1