DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 修改後的prototype.js,增加進度條和驗證輸入框
修改後的prototype.js,增加進度條和驗證輸入框
編輯:關於JavaScript     

使用示例
<script type="text/javascript" src="../scripts/prototype.js"></script>
<script type="text/javascript">
var progressBar;
/**//*
* 功能:admin登錄
*/
function UserLogin()
{
   
    //驗證頁面控件
    var checkform = new CheckForm();
    if(!checkform.checkForm(document.getElementById('formLogin'))) return false;   
       
    //開始提交數據
    progressBar = new ProgressBar();
    progressBar.SetStatus("正在發送數據到服務器.");
   
    var url = "../admin.do";
    var pars = "action=Login&username=" + $F('username') + "&password=" + $F('password') + "&rnd=" +$F('rnd');
    var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: UserLogin_CallBack}
    );
}
/**//*
* 功能:admin登錄 - CallBack
*/
function UserLogin_CallBack(originalRequest)
{
  var objXml = originalRequest.responseXML;
  //alert(originalRequest.responseTEXT);
  try
  {
    if(objXml.getElementsByTagName("return")[0].firstChild.nodeValue == "true")
    {
      progressBar.isNeedConfirmButton = false;
      progressBar.isNeedProgressBar = true;
      progressBar.SetStatus("<img src='/images/NullPic.gif' align='absmiddle'> 登錄成功,正在載入,請稍候..");

      //login success
      location.href='admin_index.htm';
    }
    else
    {
      progressBar.isNeedConfirmButton = true;
      progressBar.isNeedProgressBar = false;
      progressBar.focusItem = "username";
      progressBar.SetStatus("<img src='/images/NullPic.gif' align='absmiddle'> 對不起,登錄失敗!" + objXml.getElementsByTagName("msg")[0].firstChild.nodeValue);

      $('btnOK').disabled = false;
    }
  }
    catch(err)
    {
      progressBar.isNeedConfirmButton = true;
      progressBar.isNeedProgressBar = false;
      progressBar.focusItem = "username";
      progressBar.SetStatus("<img src='/images/NullPic.gif' align='absmiddle'> 對不起,登錄失敗!" + err.message);

      $('btnOK').disabled = false;
    }
  }
</script>

<table width="100%" border="0" cellpadd

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved