2013-02-22 58 views
2

我是Asp.Net(MVC)的新成員。我創建了一個ASP.Net MVC Mobile頁面。頁面輸出如下所示... jQuery只是不會觸發UserName文本框的textchange。請讓我知道如果我失去了一些東西。JQuery不能在ASP.Net MVC頁面中工作

<!DOCTYPE html> 
<html lang="en" > 
    <head><meta charset="utf-8" /><title> 
    XYZ 
</title><meta name="viewport" content="width=device-width" /> 
     <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
     <link href="/Content/jquery.mobile-1.1.0.css" rel="stylesheet"/> 
     <link href="/Content/jquery.mobile.structure-1.1.0.css" rel="stylesheet"/> 
     <link href="/Content/jquery.mobile.theme-1.1.0.css" rel="stylesheet"/> 
     <link href="/Content/site.css" rel="stylesheet"/> 
     <script src="/Scripts/modernizr-2.5.3.js"></script> 

    <script> 
     $(document).ready(function() { 
      $("#UserName").change(function() { 
       alert("Text Entered Is :"+$("#UserName").val()); 
      }); 
     }); 
    </script> 


</head> 
    <body> 
     <div data-role="page" data-theme="b"> 
      <div data-role="header"> 
        <h1>Forgot Password?</h1> 
        <a data-icon="star" href="/Account/Login">Log in</a> 
      </div> 
      <div data-role="content"> 

<p>Specify your login name and answer the secret question. If user name and secret answer matches; new password will be mailed to your registered email id.</p> 
<form action="/Account/ForgotPassword" method="post"><div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li> 
</ul></div> 
    <ul data-role="listview" data-inset="true"> 
     <li data-role="list-divider">Confirm...</li> 

     <li data-role="fieldcontain"> 
      <label for="UserName">User name</label> 
      <input data-val="true" data-val-required="The User name field is required." id="UserName" name="UserName" type="text" value="" /> 
     </li> 

     <li data-role="fieldcontain"> 
      <label for="SecurityQuestion">Security Question</label> 
      <input data-val="true" data-val-required="The Security Question field is required." id="SecurityQuestion" name="SecurityQuestion" readonly="readonly" type="text" value="" /> 
     </li> 

     <li data-role="fieldcontain"> 
      <label for="SecurityAnswer">Security Answer</label> 
      <input data-val="true" data-val-required="The Security Answer field is required." id="SecurityAnswer" name="SecurityAnswer" type="text" value="" /> 
     </li> 

     <li data-role="fieldcontain"> 
      <input type="submit" value="Retrieve Password" /> 
     </li> 
    </ul> 
</form> 
      </div> 
     </div> 

     <script src="/Scripts/jquery-1.7.1.js"></script> 
<script src="/Scripts/jquery.mobile-1.1.0.js"></script> 


    <script src="/Scripts/jquery.unobtrusive-ajax.js"></script> 
<script src="/Scripts/jquery.validate.js"></script> 
<script src="/Scripts/jquery.validate.unobtrusive.js"></script> 


    </body> 
</html> 

回答

0

將此行移到jquery函數的上面。

<script src="/Scripts/jquery-1.7.1.js"></script> 
+0

它的工作!萬分感謝!!!但IE仍然失敗(我正在使用IE9) – NewToAspMVC 2013-02-22 09:43:16

相關問題