javascript处理表单示例(javascript提交表单)(2)

//TODO Add suppport to allow save and stay
     if(btn_action =='reqonly'){
      if(returi = form.attr('returi')){
       $(window).data('blockUI.returi',returi);
       ajaxAutoUnblock = false;
      }
      $.blockUI({ message:retData, css:{ cursor:'pointer',padding:'4px',border:'3px solid #CC0000',}, overlayCSS:{ cursor:'pointer' } });
      $(".blockUI").addClass("blockwarn");
     } //if there is returi set, then return to uri
     else if(returi = form.attr('returi')){
      window.location = returi;
     //Else if reload is set, then will be reload
     }else if(form.attr('reload')!=undefined){
      window.location.reload();
     }else{
      $.blockUI({ message:retData });
      $.unblockUI();
     }
    }
    else{
     if(typeof (json.data.errmsg) == 'string'){
      errHint.html(json.data).show();
      //$.blockUI({ message:json.data, css:{ cursor:'pointer',padding:'4px',border:'3px solid #CC0000',}, overlayCSS:{ cursor:'pointer' } });
      //$(".blockUI").addClass("blockwarn");
     }else{
      errHint.html("{Html::text(__('E_FORM'))}").show();
      for(var p in json.data){
       var msg = json.data[p];
       //Process hidden value,None hidden input should has refid refered to hidden value
       //Showing the Server message to ref
       var ele = form.find("[type=hidden][name="+p+"]");
       if(ele.length){
        delete json.data.p;
        refid = ele.attr("id");
        refname = form.find("[hidden-id="+refid+"]").attr("name");
        json.data[refname]=+msg;
       }

//Muti checkbox
       var ele = form.find("[type=checkbox][name='"+p+"[]']");
       if(ele.length){
        delete json.data.p;
        refname = p+'[]';
        json.data[refname]=+msg;
       }
       //@END
      }
     }
     /*
      * Checking the hidden values
      */
     form.data("validator").invalidate(json.data);
    } },'json');
    e.preventDefault();
 }else{
  errHint.html("{Html::text(__('E_FORM'))}").show();
 }
};

/***
 * Reset the input
 */
var ajax_post_form_hidden = function(){
  var form  = $(this);

form.find("[hidden-id]").each(function(){
   //Clear the message of Reference
   var input = $(this);
   var refid = input.attr("hidden-id");
   var field = $("#" + refid + "");
   //Setup the clear of Errmsg
   //Monitor the change event on ID element, remove error message
   //of Real input
   field.change(function(){
    //Hidden input
    var hinput  = $(this);
    //real input
    var rinput = $("[hidden-id="+hinput.attr("id")+"]").first();
    form.data('validator').reset(rinput)
    });
   });
  };

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgppsz.html