0

次のように入力すると、フォームがあります。

<form name="formLogin" id="formLogin" action="index.aspx" method="post">

私のJavaScriptは機能し、Webページのソースコードは上記と同じです。

次のように入力すると、次のようになります。

<form name="formLogin" id="formLogin" runat="server">

私のページが壊れています。私は基本的にサードパーティのテンプレートを使用していて、それをasp.netに変換しようとしています。

表示されるソースコードは次のとおりです。

<form id="formLogin" action="index.aspx" method="post">

runat="server"このオプションを使用すると、名前のないフォーム要素が再作成されるようです。runtat="server".netで、Jqueryとサーバー側の検証を処理したい場合は使用する必要がありますか?

を含めない場合でも、コードビハインドページで検証できますrunat="Server"か?

      $(document).ready(function () {     
            onfocus();
            $(".on_off_checkbox").iphoneStyle();
            $('.tip a ').tipsy({gravity: 'sw'});
            $('#login').show().animate({   opacity: 1 }, 2000);
            $('.logo').show().animate({   opacity: 1,top: '30%'}, 800,function(){           
                $('.logo').show().delay(1200).animate({   opacity: 1,top: '0%' }, 300,function(){
                    $('.formLogin').animate({   opacity: 1,left: '0' }, 300);
                    $('.userbox').animate({ opacity: 0 }, 200).hide();
                 });        
            })  
        }); 

        $('.userload').click(function(e){
            $('.formLogin').animate({   opacity: 1,left: '0' }, 300);               
              $('.userbox').animate({ opacity: 0 }, 200,function(){
                  $('.userbox').hide();             
               });
        });

    $('#but_login').click(function(e){              
          if(document.formLogin.username.value == "" || document.formLogin.password.value == "") // BREAKS HERE
          {
              showError("Please Input Username / Password");
              $('.inner').jrumble({ x: 4,y: 0,rotation: 0 });   
              $('.inner').trigger('startRumble');
              setTimeout('$(".inner").trigger("stopRumble")',500);
              setTimeout('hideTop()',5000);
              return false;
          }     
         hideTop();
         loading('Checking',1);     
         setTimeout( "unloading()", 2000 );
         setTimeout( "Login()", 2500 );
    }); 

function Login(){
    $("#login").animate({   opacity: 1,top: '49%' }, 200,function(){
         $('.userbox').show().animate({ opacity: 1 }, 500);
            $("#login").animate({   opacity: 0,top: '60%' }, 500,function(){
                $(this).fadeOut(200,function(){
                  $(".text_success").slideDown();
                  $("#successLogin").animate({opacity: 1,height: "200px"},500);                  
                });                           
             }) 
     }) 
    setTimeout( "window.location.href='dashboard.html'", 3000 );
}

$('#alertMessage').click(function(){
    hideTop();
});

function showError(str){
    $('#alertMessage').addClass('error').html(str).stop(true,true).show().animate({ opacity: 1,right: '0'}, 500);   

}

function showSuccess(str){
    $('#alertMessage').removeClass('error').html(str).stop(true,true).show().animate({ opacity: 1,right: '0'}, 500);    
}

function onfocus(){
                if($(window).width()>480) {                   
                        $('.tip input').tipsy({ trigger: 'focus', gravity: 'w' ,live: true});
                }else{
                      $('.tip input').tipsy("hide");
                }
}

function hideTop(){
    $('#alertMessage').animate({ opacity: 0,right: '-20'}, 500,function(){ $(this).hide(); });  
}   

function loading(name,overlay) {  
      $('body').append('<div id="overlay"></div><div id="preloader">'+name+'..</div>');
              if(overlay==1){
                $('#overlay').css('opacity',0.1).fadeIn(function(){  $('#preloader').fadeIn();  });
                return  false;
         }
      $('#preloader').fadeIn();   
 }

 function unloading() {  
        $('#preloader').fadeOut('fast',function(){ $('#overlay').fadeOut(); });
 }
4

1 に答える 1

1

そうrunat=Serverしないと、実際のフォームやコード ビハインド (サーバー側) で runat=server とマークされていないコントロールにアクセスできなくなります。jquery コードを投稿してください。何かおかしなことがあれば、この回答を編集できます。

パスワードに と 同じを使用$("#username").val().lengthして、名前/パスワードが存在するかどうかを確認します。js と jquery の両方が混同されているため、原因を見つけるのがさらに難しくなっています。

if($("#username").val().length == 0 && $("#password").val().length == 0)

  //enter here if one is missing
于 2012-04-12T19:25:16.683 に答える