2013-04-26 2 views
0

제 코드는 IE7에서 작동하지만 객체 요구 오류가있어서 chrome 및 firefox에서는 작동하지 않습니다. 도와주세요. 아래 코드는 입니다. IE7 브라우저는 jquery 기능의 시작부터 오류를 표시하지만 계속 진행할 수 있습니다. 하지만 크롬과 사파리에서는 제출 버튼과 Validate() 함수가 작동하지 않습니다.

  <link rel="stylesheet" type="text/css" href="css/style.css" /> 
      <script src="js/cufon-yui.js" type="text/javascript"></script> 
      <script src="js/ChunkFive_400.font.js" type="text/javascript"></script> 
      <script type="text/javascript"> 
      Cufon.replace('h1',{ textShadow: '1px 1px #fff'}); 
      Cufon.replace('h2',{ textShadow: '1px 1px #fff'}); 
      Cufon.replace('h3',{ textShadow: '1px 1px #000'}); 
      Cufon.replace('.back'); 
      </script> 
      <script type="text/javascript"> 
      function validate(){ 
      var Uname=document.getElementById("username") 
      if(Uname.value==""||Uname.value==null){ 
      alert("Enter Your User Name") 
      Uname.focus() 
      return false 
      } 
      if(Uname.value.length<6){ 
      alert("Min-6 characters for your UserName") 
      Uname.focus() 
      return false 
      } 
      var pass=document.getElementById("password") 
      if(pass.value==""||pass.value==null){ 
      alert("Enter Your Password") 
      pass.focus() 
      return false 
      } 
      if(pass.value.length<6){ 
      alert("Min-6 characters for your Password") 
      pass.focus() 
      return false 
      } 
      return true 
      } 
      </script> 
      </head> 
      <body> 
      <div class="wrapper"> 
      <h1>User Management</h1> 
      <div class="content"> 
      <div id="form_wrapper" class="form_wrapper"> 
      <form class="login active" onSubmit="return validate() action="login.php" method="post"> 
      <h3>Login</h3> 
      <div> 
      <label>Username:</label> 
      <input type="text" id="username"/> 
      <span class="error">enter ur email id</span> 
      </div> 
      <div> 
      <label>Password: </label> 
      <input type="password" id="password"/><a href="forgot_password.html" rel="forgot_password" class="forgot linkform">Forgot your password?</a> 
      </div> 
      <div class="bottom"> 
      <input type="submit" value="Login"></input> 
      <div class="clear"></div> 
      </div> 
      </form> 
      <form class="forgot_password" onSubmit="return validate() action="forgotpassword.php" method="post"> 
      <h3>Forgot Password</h3> 
      <div> 
      <label>Username</label> 
      <input type="text" /> 
      <span class="error">enter ur email id</span> 
      </div> 
      <div class="bottom"> 
      <input type="submit" value="Send reminder"></input> 
      <a href="index.php" rel="login" class="linkform">Suddenly remebered? Log in here</a> 
      <div class="clear"></div> 
      </div> 
      </form> 
      </div> 
      <div class="clear"></div> 
      </div> 

      </div> 


      <!-- The JavaScript --> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
      <script type="text/javascript"> 
      $(function() { 
      //the form wrapper (includes all forms) 
      var $form_wrapper = $('#form_wrapper'), 
      //the current form is the one with class active 
      $currentForm = $form_wrapper.children('form.active'), 
      //the change form links 
      $linkform  = $form_wrapper.find('.linkform'); 

      //get width and height of each form and store them for later       
      $form_wrapper.children('form').each(function(i){ 
      var $theForm = $(this); 
      //solve the inline display none problem when using fadeIn fadeOut 
      if(!$theForm.hasClass('active')) 
      $theForm.hide(); 
      $theForm.data({ 
      width : $theForm.width(), 
      height : $theForm.height() 
      }); 
      }); 

      //set width and height of wrapper (same of current form) 
      setWrapperWidth(); 

      /* 
      clicking a link (change form event) in the form 
      makes the current form hide. 
      The wrapper animates its width and height to the 
      width and height of the new current form. 
      After the animation, the new form is shown 
      */ 
      $linkform.bind('click',function(e){ 
      var $link = $(this); 
      var target = $link.attr('rel'); 
      $currentForm.fadeOut(400,function(){ 
      //remove class active from current form 
      $currentForm.removeClass('active'); 
      //new current form 
      $currentForm= $form_wrapper.children('form.'+target); 
      //animate the wrapper 
      $form_wrapper.stop() 
      .animate({ 
      width : $currentForm.data('width') + 'px', 
      height : $currentForm.data('height') + 'px' 
      },500,function(){ 
      //new form gets class active 
      $currentForm.addClass('active'); 
      //show the new form 
      $currentForm.fadeIn(400); 
      }); 
      }); 
      e.preventDefault(); 
      }); 

      function setWrapperWidth(){ 
      $form_wrapper.css({ 
      width : $currentForm.data('width') + 'px', 
      height : $currentForm.data('height') + 'px' 
      }); 
      } 


      $form_wrapper.find('input[type="submit"]') 
      .click(function(e){ 
      e.preventDefault(); 
      }); 
      }); 
      </script> 
      </body> 
+1

세미콜론을 사용하십시오! 텍스트 상자의 값은 null 일 수 없으며 검사는 쓸모가 없습니다. 마지막으로 코드를 들여 쓰지 않습니까? 그것은 당신의 오류를 찾는 데 도움이 될 것입니다. – epascarello

+0

되돌리기 [이 제안 된 잘못된 편집] (http://stackoverflow.com/review/suggested-edits/2000373#./2000373) 원래 게시물의 문장의 의미가 변경되었습니다. –

답변

1

클래스에 대한 onSubmit에는 닫는 큰 따옴표가 없습니다.

<form class="login active" onSubmit="return validate()**"** action="login.php" method="post"> 

그러면 문제가 해결되고 이벤트가 트리거됩니다.

+0

그건 작은 오류입니다 .... 나는 그것을 고쳤습니다. 그러나 여기에서도 다시 $ function에 object error라는 오류가 나타납니다. 그러나 이것은 인트라넷 서버의 모든 브라우저에서 ie7 local system 및 .shows 오류에서 작동합니다. 답장을 보내 주셔서 감사합니다. – user2323550

+0

$ form_wrapper.find ('input [type = "submit"]') .click (function (e) { e.preventDefault(); }); – user2323550

+0

위의 함수는 다른 스크립트가 작동하도록 제거되었습니다. 이제는 잘 작동합니다. – user2323550