2009-09-04 4 views
2

xVal을 사용하는 MVC 앱이 있습니다. 폼이 유효하면 "로딩"그래픽을 표시하기 위해 jquery 유효성 검사에 연결하려고합니다. jquery가 양식의 유효성을 검사했을 때 qraphic 만 표시하는 방법을 찾지 못하는 것 같습니다.xVal을 사용하여 제출시 버튼 사용 안 함 MVC

그러나 단추를 클릭 할 때 단추를 사용할 수 없으며 사용자가 양식을 다시 제출하지 못하게하여 클라이언트 측 오류가 수정됩니다.

누구든지이 작업을 수행 한 경험이 있습니까?

감사

여기서 R

어쨌든 전체 페이지 소스

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title> 

    </title><link href="../Content/wri_mainstyles.css" rel="stylesheet" type="text/css" /> 

     <script type="text/javascript" src="/Scripts/jquery-1.3.js"></script> 
     <script type="text/javascript" src="/Scripts/jquery.validate.js"></script> 
     <script type="text/javascript" src="/Scripts/xVal.jquery.validate.js"></script> 

     <script type="text/javascript"> 
      $(document).ready(function() { 

       // ---- notification pane 
       $("#notify-container").fadeOut(4000); 

       // ---- tab bar related code 
       var sel; 
       $("#nav a").mouseover(function() { 
        if ($(this).data("clicked")) { return; } 
        $(this).children("img").each(function() { 
         this.src = $(this).attr("src").replace(/_off\.gif$/ig, "_on.gif"); 
        }); 
       }).mouseout(function() { 
        if ($(this).data("clicked")) { return; } 
        $(this).children("img").each(function() { 
         this.src = $(this).attr("src").replace(/_on\.gif$/ig, "_off.gif"); 
        }); 
        //handle clicks 
       }).click(function() { 
        if (sel != null) { 
         $("#nav").find("img").each(function() { 
          this.src = this.src.replace(/_clk\.gif$/i, "_off.gif"); 

         }); 
        } 
        $(this).children("img").each(function() { 
         this.src = $(this).attr("src").replace(/_on.gif$/ig, "_clk.gif"); 
        }) 
        sel = this; 
       }); 
       //panel pop up code 

       //hide panel on load. 
       $("#top-panel").hide(); 

       //toggle when clicked. 
       $("#sub-panel").click(function() { 
        $("#top-panel").slideToggle(); 
        var el = $("#shText"); 
        var state = $("#shText").html(); 
        state = (state == 'Close Panel' ? '<span id="shText">Open Panel</span>' : '<span id="shText">Close Panel</span>'); 
        el.replaceWith(state); 
       }); 

      }); 
     </script> 


    <script type="text/javascript" language="javascript"> 
     $(function() { // make this code initialize when DOM loads 
      $('#frmXL').submit(function() { 
      $('input[type="submit"]', this).replaceWith('<span id="loading"></span>'); // 
      }); 
     }); 
    </script> 




    </head> 

    <body> 
    <div class="wrapper"> 
     <div id="nav"> 
      <div id="logo"><img src="../../Content/Images/inbox_wrilogo.gif" width="143" height="28" alt="logo" border="0" /></div> 
      <div id="tab1"><a href="/Support"><img alt="Support" border="0" height="22" name="support" src="/Content/Images/nav_support_off.gif" width="75"></img></a></div> 

      <div id="tab2"><a href="/Account"><img alt="Account" border="0" height="22" name="account" src="/Content/Images/nav_acct_off.gif" width="75"></img></a></div> 
      <div id="tab3"><a href="/"><img alt="Inbox" border="0" height="22" name="inbox" src="/Content/Images/nav_inbox_off.gif" width="75"></img></a></div> 
     </div> 



    <form action="/Security/Login?ReturnUrl=%2f" id="frmXL" method="post"> 
      <div id="loginwrapper"> 

      <div id="logincontainer"> 
       <div id="logincontrol"> 
        <p> 

        <label for="username" accesskey="u">Email Address</label> 
        <input class="frmInput" id="EmailAddress" name="EmailAddress" type="text" value="" /> 

        </p> 

        <p> 
        <label for="password" accesskey="p">Password</label> 
        <input class="frmInput" id="Password" name="Password" type="password" /> 

        </p> 



        <label for="RememberMe">Remember Me</label> 

        <div id="rememberwrapper"> 
        <span class="rememberme"><input id="RememberMe" name="RememberMe" type="checkbox" value="true" /><input name="RememberMe" type="hidden" value="false" /></span> 
        </div> 

        <p> 
        <input class="frmbtnsubmit" type="submit" value="Login" /> 
        </p> 
       </div> 

       <span class="homelink"> 
       <a class="hmlink" href="/Security?Length=4">Back to Homepage</a> 

       </span> 
      </div> 
      </div> 
     </form><input name="__RequestVerificationToken" type="hidden" value="DolZ3JoPXziTgPTvWZLqxl/2z16aolj3gjZzHeB2cbs0a+6O17w9bWm3K9XOS/GX" /> 
     <script type="text/javascript">xVal.AttachValidator(null, {"Fields":[{"FieldName":"EmailAddress","FieldRules":[{"RuleName":"RegEx","RuleParameters":{"Pattern":"^(?:[a-zA-Z0-9_\u0027^&amp;/+-])+(?:\\.(?:[a-zA-Z0-9_\u0027^&amp;/+-])+)*@(?:(?:\\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\]?)|(?:[a-zA-Z0-9-]+\\.)+(?:[a-zA-Z]){2,}\\.?)$"},"Message":"Email address is invalid."},{"RuleName":"Required","RuleParameters":{},"Message":"This is a required field."},{"RuleName":"RegEx","RuleParameters":{"Pattern":"^(?:[a-zA-Z0-9_\u0027^&amp;/+-])+(?:\\.(?:[a-zA-Z0-9_\u0027^&amp;/+-])+)*@(?:(?:\\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\]?)|(?:[a-zA-Z0-9-]+\\.)+(?:[a-zA-Z]){2,}\\.?)$"},"Message":"Email address is invalid."},{"RuleName":"Required","RuleParameters":{},"Message":"This is a required field."}]},{"FieldName":"Password","FieldRules":[{"RuleName":"Required","RuleParameters":{},"Message":"This is a required field."},{"RuleName":"Required","RuleParameters":{},"Message":"This is a required field."}]}]})</script> 




    </div> 


    <!-- RDD: Do not remove this div. This help keep the footer at the bottom of the page --> 
    <div class="push"></div> 
    <!-- end --> 




    <div id="top-panel"> 
      <span id="appversion" class="footertext">Inbox Swf Version: 0.0.0.1<br />Web Application Version: 0.0.75.12305</span> 
    </div> 
    <div id="#footercontent"> 
     <div class="footer"> 
      <div id="footertext">&copy; Copyright 2009 All Rights Reserved</div> 

      <div id="sub-panel"><a title="View support panel" href="#" id="toggle"><span id="shText">Open Panel</span></a></div> 
     </div>  
    </div>  


    </body> 
    </html> 
+0

안녕하세요, "보기 소스"를하고 xVal이 출력하는 관련 자바 스크립트 코드를 찾으시겠습니까? 이미 게시 한 코드 스 니펫 위 또는 아래에 있는지 알려주십시오. xVal이하기 전에 당신의'submit' 이벤트 핸들러가 시작될 가능성이 있습니다.이 경우 ... 이미 그 부분을 발견했습니다! – Funka

+0

예, 전체 페이지 소스를 게시 해 드리겠습니다. – Rob

+0

잘 모르겠지만 무슨 일인지 잘 모르겠지만 아이디는 내가 과거를하려고 할 때 내 근원을 괴롭 히고있다. 당신이 나에게 당신의 이메일을 주면 나는 그것을 당신에게 보낼 수있다. 죄송합니다. – Rob

답변

1

이다, 난에서 preventDefault없이() 당신의 제출이 반드시 해고 될 것이라고 생각합니다.

$(function() { // make this code initialize when DOM loads 
      $('#frmXL').submit(function(e) { 
      e.preventDefault(); 
      $('input[type="submit"]', this).replaceWith('<span id="loading"></span>'); // 
      }); 
     });