aspx 中 Button 按钮先校验 textbox 必填,然后,弹出提交确认警告框

 

aspx 前台代码:

 

代码
< script type = " text/javascript "  language = " JavaScript " >

// 检查值
function  jcz1()
{

   
var  meters = document.getElementById( " <%=TextBox10.ClientID%> " );
   
var  planoil = document.getElementById( " <%=TextBox11.ClientID%> " );
   
var  actoil = document.getElementById( " <%=TextBox12.ClientID%> " );
   
var  carcategory = document.getElementById( " <%=inputcarcategory.ClientID%> " );
   
    
    
if  (carcategory.value == " 1 " )
    {
       
if  (meters.value == "" )
       {
        alert(
" \n请填写本月截止里程数! " );
        meters.focus();        
        
return   false ;
       }
    }
    
     
if  (planoil.value == "" )
    {
        alert(
" \n请填写本月计划用油! " );
        planoil.focus();        
        
return   false ;
    }
     
if  (actoil.value == "" )
    {
        alert(
" \n请填写本月实际用油! " );
        actoil.focus();        
        
return   false ;
    }
    
   
    
    
if (confirm( " 您确定提交本交燃油报表吗?提交后将不能再对数据做任何修改!请再一次仔细核对数据! " ))
    {
        
return   true ;
    }
    
else
    {
        
return   false ;
    }

    
}


        
< / script>

 

 

 

aspx.CS 后台中:

 

代码
   protected   void  Page_Load( object  sender, EventArgs e)
  {

       
if  ( ! IsPostBack)
            {
                
this .Button1.Attributes.Add( " onclick " " if(jcz1()==true){return true;}else{return false;} " );            }

       }

 

 

你可能感兴趣的:(button)