2013-07-10 5 views
0

이것은 제가 작업중인 로그인 페이지의 자바 스크립트입니다. 그래서 어떤 이유로 내 양식이 양식을 보내기 전에 유효성을 검사하지 않으며 또한 내 배경 회전 플러그인을 부러 뜨 렸습니다. 희망에 따라 누군가가이 문제를 해결할 수 있도록 도와 드리겠습니다. 죄송합니다.이 텍스트가 너무 길면 자세한 내용을 추가 할 것을 요청하기 때문에이 게시물을 올바르게 제출할 수 없습니다.하지만 실제로는 알지 못합니다. 그 밖의 무엇에 추가 할 수 있습니다.양식 유효성 검사가 수행되지 않고 양식 제출

var Login = function() { 

    return { 
     //main function to initiate the module 
     init: function() { 

      $.backstretch([ 
       "assets/img/bg/1.jpg", 
       "assets/img/bg/2.jpg", 
       "assets/img/bg/3.jpg", 
       "assets/img/bg/4.jpg" 
       ], { 
        fade: 1000, 
        duration: 8000 
       }); 

      $('.login-form').submit(function(e) { 
      e.preventDefault(); 
      }).validate({ 
       errorElement: 'label', //default input error message container 
       errorClass: 'help-inline', // default input error message class 
       focusInvalid: false, // do not focus the last invalid input 
       rules: { 
        username: { 
         required: true 
        }, 
        password: { 
         required: true 
        }, 
        remember: { 
         required: false 
        } 
       }, 

       messages: { 
        username: { 
         required: "Username is required." 
        }, 
        password: { 
         required: "Password is required." 
        } 
       }, 

       invalidHandler: function (event, validator) { //display error alert on form submit 
        $('.alert-error', $('.login-form')).show(); 
       }, 

       highlight: function (element) { // hightlight error inputs 
        $(element) 
         .closest('.control-group').addClass('error'); // set error class to the control group 
       }, 

       success: function (label) { 
        label.closest('.control-group').removeClass('error'); 
        label.remove(); 
       }, 

       errorPlacement: function (error, element) { 
        error.addClass('help-small no-left-padding').insertAfter(element.closest('.input-icon')); 
       }, 

       submitHandler: function (form) { 
        $.ajax({ 
        url: "loginqry.php", 
        type: "post" 
        data: serializedData 
        { 
        alert(data); // show response from the php script. 
        } 
        }); 
        return false; 
       } 
      }); 

      $('.login-form input').keypress(function (e) { 
       if (e.which == 13) { 
        $.ajax({ 
        url: "loginqry.php", 
        type: "post" 
        data: serializedData 
        { 
        alert(data); // show response from the php script. 
        } 
        }); 
        return false; 
       } 
      }); 
     } 

    }; 

}(); 

답변

0

당신은 .validate() method을 체인 수없는 이벤트 핸들러에 ...

$('.login-form').submit(function(e) { 
    e.preventDefault(); 
}).validate({...}); 

은 또한, 제 자리에 .submit() 핸들러를 선언 할 이유가 없다. 플러그인은 양식을 바인드 한 양식의 제출 이벤트를 자동으로 처리합니다.

간단하게이 대신 ...

$('.login-form').validate({...}); 
관련 문제