2010-04-10 6 views
0

인사말, 나는 JQuery와 플러그인/검증 라이브러리를 사용하고JQuery와 플러그인/검증하여 submitHandler

. 제출시 유효성 검사를 허용하고 싶지만 코드를 삽입해야하는 위치를 모르겠습니다. 사용자 submitHandler를 사용할 수 있지만 문서를 읽은 후 구현하기가 힘들어서 도움이 필요합니다.

jquery 유효성 검사는 정상적으로 작동하지만 양식에 여전히 잘못된 입력이 있어도 문제가 발생합니다.

여기 내 유효성 검사 기능이며 유효하지 않은 입력이있는 경우 어떻게 양식을 제출하지 않을 수 있는지 알고 싶습니다.

그건 그렇고, 양식을 제출 asp.net 버튼을 사용하고 있습니다.

$(document).ready(function() { 


      $("#aspnetForm").validate({ 




       rules: { 
        "<%=txtHomePhone.UniqueID %>": { 

         phonehome: true 
        }, 

        "<%=txtMobileHome.UniqueID %>": { 

         mobilephone: true 


       }, 

        "<%=txtFaxHome.UniqueID %>": { 

        faxhome: true 

       }, 

       "<%=txtEmailHome.UniqueID %>": { 

        email: true 

       }, 


       "<%=txtZipCodeHome.UniqueID %>": { 

       ziphome: true 

       }, 

       //work 
          "<%=txtPhonework.UniqueID %>": { 

         phonework: true 
        }, 

        "<%=txtMobileWork.UniqueID %>": { 

         mobilework: true 


       }, 

        "<%=txtFaxWork.UniqueID %>": { 

        faxwork: true 

        }, 
        "<%=txtEmailWork.UniqueID %>": { 

        email: true 

       }, 

       "<%=txtWebSite.UniqueID %>": { 

        url: true 

       }, 
       "<%=txtZipWork.UniqueID %>": { 

       zipwork: true 

       } 



       }, 




        errorElement: "mydiv", 
        wrapper: "mydiv", // a wrapper around the error message 

         errorPlacement: function(error, element) { 
         offset = element.offset(); 
         error.insertBefore(element) 
         error.addClass('message'); // add a class to the wrapper 
         error.css('position', 'absolute'); 
         error.css('left', offset.left + element.outerWidth()); 
         error.css('top', offset.top - (element.height()/2)); 

        } 



      }); 

답변

0

하는 debugon 수 있도록이 줄을 추가하여 나는 규칙에 대한 유효성 검사 기능에서 true로 디버그를 설정해야 제출 : 디버그 : 여기

내 코드는 사실을,

정확한 코드 :

$(document).ready(function() { 


     $("#aspnetForm").validate({ 


       debug: true, 

      rules: { 
       "<%=txtHomePhone.UniqueID %>": { 

        phonehome: true 
       }, 

       "<%=txtMobileHome.UniqueID %>": { 

        mobilephone: true 


      }, 

       "<%=txtFaxHome.UniqueID %>": { 

       faxhome: true 

      }, 

      "<%=txtEmailHome.UniqueID %>": { 

       email: true 

      }, 


      "<%=txtZipCodeHome.UniqueID %>": { 

      ziphome: true 

      }, 

      //work 
         "<%=txtPhonework.UniqueID %>": { 

        phonework: true 
       }, 

       "<%=txtMobileWork.UniqueID %>": { 

        mobilework: true 


      }, 

       "<%=txtFaxWork.UniqueID %>": { 

       faxwork: true 

       }, 
       "<%=txtEmailWork.UniqueID %>": { 

       email: true 

      }, 

      "<%=txtWebSite.UniqueID %>": { 

       url: true 

      }, 
      "<%=txtZipWork.UniqueID %>": { 

      zipwork: true 

      } 



      }, 




       errorElement: "mydiv", 
       wrapper: "mydiv", // a wrapper around the error message 

        errorPlacement: function(error, element) { 
        offset = element.offset(); 
        error.insertBefore(element) 
        error.addClass('message'); // add a class to the wrapper 
        error.css('position', 'absolute'); 
        error.css('left', offset.left + element.outerWidth()); 
        error.css('top', offset.top - (element.height()/2)); 

       } 



     });