澳门金莎娱乐网站:javascript处理表单示例_基础知

日期:2019-12-05编辑作者:服务器

以上就是本文的全部内容了,希望对大家能够有所帮助。

EasyUI中实现form表单提交的示例分享

  这里给大家分享的是一段使用EasyUI中实现form表单提交的方法的核心代码,小伙伴们根据自己的需求补全form部分吧,希望大家能够喜欢。

  代码如下:

  $('#form').form({

  url : 'test/add.do',

  onSubmit : function() {

  parent.$.messager.progress({

  title : '提示',

  text : '数据处理中,请稍后....'

  });

  var gridValid = endEdit();// 子表退出编辑验证

  if (!gridValid) {

  parent.$.messager.progress('close');

  return false;

  }

  var isValid = $('#form').form('validate');

  if (!isValid) {

  parent.$.messager.progress('close');

  return false;

  }

  // 将子表中添加修改删除的数据写入隐藏input

  accept();

  return true;

  },

  success : function(result) {

  parent.$.messager.progress('close');

  try {

  data = eval("(" + result + ")");// 将JSON字符串转换成对象

  if (data && data.success) {

  if (data.msg && data.msg != "")

  parent.$.messager.alert('提示', data.msg);

  else

  parent.$.messager.alert('提示', "添加成功");

  parent.$.modalDialog.openner_grid.datagrid('reload');// 刷新Gird数据

  parent.$.modalDialog.handler.dialog('close');// 关闭当前模式窗口

  } else

  parent.$.messager.alert('错误', data.msg);// 操作失败

  } catch (e) {

  parent.$.errorDialog(result);// 提示服务器异常

  }

  }

  });

 

  以上就是本文的全部内容了,希望对大家能够有所帮助。

 

这里给大家分享的是一段使用EasyUI中实现form表单提交的方法的核心代码,小伙伴们根据自己的需求补全...

EasyUI中实现form表单提交的示例分享,easyuiform

复制代码 代码如下:
 $('#form').form({
  url : 'test/add.do',
  onSubmit : function() {
   parent.$.messager.progress({
    title : '提示',
    text : '数据处理中,请稍后....'
   });
   var gridValid = endEdit();// 子表退出编辑验证
   if (!gridValid) {
    parent.$.messager.progress('close');
    return false;
   }
   var isValid = $('#form').form('validate');
   if (!isValid) {
    parent.$.messager.progress('close');
    return false;
   }
   // 将子表中添加修改删除的数据写入隐藏input
   accept();
   return true;
  },
  success : function(result) {
   parent.$.messager.progress('close');
   try {
    data = eval("(" + result + ")");// 将JSON字符串转换成对象
    if (data && data.success) {
     if (data.msg && data.msg != "")
      parent.$.messager.alert('提示', data.msg);
     else
      parent.$.messager.alert('提示', "添加成功");
     parent.$.modalDialog.openner_grid.datagrid('reload');// 刷新Gird数据
     parent.$.modalDialog.handler.dialog('close');// 关闭当前模式窗口
    } else
     parent.$.messager.alert('错误', data.msg);// 操作失败
   } catch (e) {
    parent.$.errorDialog(result);// 提示服务器异常
   }
  }
 });

以上就是本文的全部内容了,希望对大家能够有所帮助。

复制代码 代码如下: $('#form').form({ url : 'test/add.do', onSubmit : function() { parent.$.messager.progress({ t...

/*** Matched errors with input * Only matched errors could be identified here*/var advance_validate = function {var conf = this.getConf();// loop errors$.each(errors, function {// add error class into input Dom elementvar input = error.input;

复制代码 代码如下:$.form({ url : 'test/add.do', onSubmit : function() { parent.$.messager.progress({ title : '提示', text : '数据处理中,请稍后....' }); var gridValid = endEdit();// 子表退出编辑验证 if { parent.$.messager.progress; return false; } var isValid = $.form; if { parent.$.messager.progress; return false; } // 将子表中添加修改删除的数据写入隐藏input accept(); return true; }, success : function { parent.$.messager.progress; try { data = eval;// 将JSON字符串转换成对象 if { if (data.msg && data.msg != "") parent.$.messager.alert; else parent.$.messager.alert; parent.$.modalDialog.openner_grid.datagrid;// 刷新Gird数据 parent.$.modalDialog.handler.dialog;// 关闭当前模式窗口 } else parent.$.messager.alert;// 操作失败 } catch { parent.$.errorDialog;// 提示服务器异常 } }});

相关文章

相关搜索:

今天看啥

搜索技术库

返回首页

  • IOS8天气应用可以显示细节数据技巧
  • CAD迷你看图如何查看设备清单
  • 华为Mate7如何开启按电源键结束通话
  • 电脑回收站无法调整容量的大小怎么办?
  • 新三板是什么意思
  • 如何在win7旗舰版电脑中删除U盘使用历史记录

相关频道: HTML/CSS  HTML5  Javascript  jQuery  AJax教程  前端代码  正则表达式  Flex教程  WEB前端教程  

return field.val() ? true : msg; };

var max = spin.attr{config.max = max;}

console.log('btn action:'+btn_action);//Add extra Datavar post_data;if(post_data = form.data{for {//if post_data[k] is array,need more to doformArray.push( { name:k ,value: post_data[k] } );}form.removeData;}$.post, formArray,function.data == 1){$.unblockUI();}if{var returi = "";var retData = "{__}!";if{retData = json.data;}

ipt.dateinput;return true;};

/*** Supporting the button base navigation* Only jump to new href*/var btn_nav = function;var href = input.attr{window.location = href;}else{alert;}return false;};

var refclass = check.attr;if{if){$.prop;}else{$.prop;}}};

var aft_script;//Run current after scriptif(aft_script = lookup.attr{window.eval;}

//Force unblockUI$.click{if.data == 1){$.unblockUI();var returi = $.data;if{window.location = returi;}}});

if{_c_select.find("[value="+_rowvalue[_k]+"]").prop;_c_select.change();}}};

/*** Select pick list*/var picklistchange = function (){var _select = $;var _hidden_id = _select.attr;var _un = _select.attr;

/*** Generic Ajax Form post function* If btn_action is set, then add data into form* if returi is set, redirect to returi* if reload is set, reload * else Show block message** the form will be validated.*/var ajax_form_post = function;var pre_script;if(pre_script = form.attr{var ret = eval;if{return false;}}var errHint = form.find;if{errHint = $;}errHint.text;

var pre_script;if(pre_script = l.attr{var ret = eval;if{return false;}}

var min = ipt.attr{config.min = min;}

处理各种表单, 以及链接,按钮的通用组件

/*** Select List disable*/var readonlySelect = function.prop; };

input.addClass;

/**** Reset the input*/var ajax_post_form_hidden = function;

//This is value of Current Selectvar _selected = _select.find;if(_selected.attr=="{DB::T}"){$.val;_select.after("澳门金莎娱乐网站 1");}else{var _val = _select.val();var _k = _selected.attr;

/*** Init the timePicker*/var time_picker = function;var config = { };

_select.nextAll;

$.append.appendTo;for(var _kid in _lovchildren){var _lov = _lovchildren[_kid]['lov'];$.val.append.attr.attr('is_leaf',_lov.is_leaf).appendTo;}_select.change;

pid.val);//Only operation from opener could trigger change eventpid.change.attr;pname.change();//Parent after_scriptif(aft_script = pname.attr{opener.window.eval;}if(aft_script = pid.attr{opener.window.eval;}window.close();};

var lookup_new = function(){var lookup = $;var pre_script;if(pre_script = lookup.attr{var ret = eval;if{return false;}}var url = lookup.attr{alert;return false;}var height = lookup.attr{height = 600;}var width = lookup.attr{width = 800;}window.open(url,"pselect","scrollbars=yes,menubar=no,height="+height+",width="+width+",resizable=yes,toolbar=no,location=no,status=no");return false;};

/*** When refname is contained to be selected*/var checkall = function() { var check = $;var refname = check.attr;if{if){$("input[name*='"+refname+"']").prop;}else{$("input[name*='"+refname+"']").prop;}}

$.blockUI({ message:"{__;

//Remove all the subsequent var _lovtree = _select.data;var _rowvalue = _select.data;

/*** Push button action [btn_action]data into form* If there is prescript , run the pre script*/"use strict";//All ajax request are synchronized by defaultvar ajaxSynchronized = true;//All ajax request will be unblock by defaultvar ajaxAutoUnblock = true;

var block = input.attr;if{ajaxAutoUnblock = false}

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

/*** Update the extra form data in FormElement with Form element, Key and Value*/var ajax_update_post_data = function{var form = $;var post_data = form.data;if( post_data == undefined ){post_data = {};}

var hint = input.attr{var errHint = $;if{errHint = $;}errHint.text;}

//insert into correct position (relative to the field)

//TODO Add suppport to allow save and stayif(btn_action =='reqonly'){if(returi = form.attr.data('blockUI.returi',returi);ajaxAutoUnblock = false;}$.blockUI({ message:retData, css:{ cursor:'pointer',padding:'4px',border:'3px solid #CC0000',}, overlayCSS:{ cursor:'pointer' } });$.addClass;} //if there is returi set, then return to urielse if(returi = form.attr{window.location = returi;//Else if reload is set, then will be reload}else if!=undefined){window.location.reload();}else{$.blockUI;$.unblockUI();}}else{if(typeof == 'string'){errHint.html;//$.blockUI({ message:json.data, css:{ cursor:'pointer',padding:'4px',border:'3px solid #CC0000',}, overlayCSS:{ cursor:'pointer' } });//$.addClass;}else{errHint.html("{Html::text.show();for{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{delete json.data.p;refid = ele.attr;refname = form.find.attr;json.data[refname]=+msg;}

$.get,function{if{var retData = "{__}!";var returi;//If success to execute funtion for eachvar successFunc = l.attr;if{l.each;}

//Getting Children listif(_lovtree.c[_k].c == undefined){return false;}var _c_lovtree = _lovtree.c[_k];

var min = spin.attr{config.min = min;}

/*** Crete Root picklist */var picklistinit = function(){var _select = $;var _hidden_id = _select.attr;var _un = _select.attr;var _lovchildren = _select.data.c;var _rowvalue = _select.data;

$.tools.validator.addEffect("advanced", advance_validate,advance_inputs);$.tools.validator.fn("[data-equals]", { "{lang}":"{__}" }, data_equals_validate );$.tools.validator.fn("[hidden-id]",validate_hidden_id);

var validate_hidden_id = function {var refid = input.attr;var field = $; var msg = field.attr{msg = "{__}";}

$.validator({ lang:'{lang}',effect:'advanced' }) .submit;$.each(ajax_post_form_hidden);$.each;$.each;$.each;

复制代码 代码如下:/*** Generic Form processing js* @author Anthony.chen*/

var ajax_action_button = function ;//Add prescriptvar pre_script;if(pre_script = btn.attr{var ret = eval;if{return false;}}var btn_action = btn.attr;if.closest.data('btn_action',{ name:'btn_action',value:btn_action });}};

/*** Ajax request through link* If confirm is set, confirm before send request* Support returi and reload* Else show block message*/var ajax_link_req = function;var hint = l.attr{var errHint = $;errHint.text;}//If the confirm message is set, then should be confirmed from clientif{if(!confirm{return false;}}

//Select the listif{_select.find("[value="+_rowvalue[0]+"]").prop;_select.change();}return true;};

$.get{if{var returi;if(returi = input.attr{window.location = returi;}else if!=undefined){window.location.reload();}else{var retData = "{__}!";if{retData = json.data;}$.blockUI({ message:retData,css:{ cursor:'pointer' },overlayCSS:{ cursor:'pointer' } });}}else{if;errHint.html.show();}else{$.blockUI({ message:json.data.errmsg, css:{ cursor:'pointer',padding:'4px',border:'3px solid #CC0000',}, overlayCSS:{ cursor:'pointer' } });$.addClass;}}},'json');return false;};

var step = ipt.attr{config.step = step;}

var _c_select = $.data.data.attr('hidden-id',_hidden_id).attr.attr;$.append.appendTo;//Building the option listfor(var _kid in _c_lovtree.c){var _lov = _c_lovtree.c[_kid]['lov'];$.val.append.attr.attr('is_leaf',_lov.is_leaf).appendTo;//Insert after_select.after;//Onchange}_c_select.change;

/*** Init the spin number*/var spin_number = function;var config = { lock:true, imageBasePath: '{webpath}/css/images/spin/', btnCss: null, txtCss: null, btnClass:'spin_btn',};var interval = spin.attr;if{config.interval = interval;}else{config.interval = 1;}

//Cleanup the pageErrorif(!e.isDefaultPrevented{//Hide all .formError$.blockUI({ message:"{__;var formArray = form.serializeArray();var btn_action_data;var btn_action;if(btn_action_data = form.data{formArray.push;form.removeData;btn_action = btn_action_data.value;}else{btn_action = '';}

// make sure the width is not full body width so it can be positioned correctlyif == msg.parent {msg.add;}

if{retData = json.data;}//IF Require warning beforeif == 'reqonly'){alert;}else if(returi = l.attr{window.location = returi;}else if!=undefined){window.location.reload();}else{$.blockUI({ message:retData, css:{ cursor:'pointer',padding:'4px',border:'3px solid #CC0000',}, overlayCSS:{ cursor:'pointer' } });$.addClass;}}else{//$.unblockUI();//Only could support Text errmsgif{errHint.text;}else{alert;}}},'json');return false;};

$.fileupload({url: endpointurl,autoUpload:true,dataType:'json',formData: [{ 'sessionid': sid }],paramName: 'Filedata',}).bind('fileuploaddone',window[completeFunc]);};

/*** Init the date input*/var date_input = function;var config = {offset:[4,0],selectors:true,lang: '{lang}',firstDay : 1,format: 'yyyy-mm-dd',};var min = ipt.attr{config.min = min;}

var advance_inputs = function {var conf = this.getConf();inputs.removeClass.each {var msg = $;if ;msg.parent().removeClass;if == 0){var form = $;var errHint = form.find;if{errHint = $;errHint.text;}}};

$.click;$.click;$.click;$.click;$.click;$.click;$.click;$.click;$; $.tooltip({ position:"center right"});

//At last we will do localize$.tools.validator.localize("{lang}", {'*' : "{__}",':email' : "{__}",':number' : "{__}",':url' : "{__}",'[max]' : "{__}",'[min]' : "{__}",'[required]' : "{__;});

/*** Support button base Ajax get method request* support returi and reload*/var btn_req = function;var href = input.attr;

/*** Default upload complete*///var uploadComplete = function(event, id, fileName, responseJSON) { var uploadComplete = function { //To be replaced by jquery uploadervar _fileUpload = $;//console.log;//console.log;if(_fileUpload.attr{window.location.reload();}};

$.click;//Client validation for the hidden ID $.validator({ lang:'{lang}',effect:'advanced' });

form.find.each{//Clear the message of Reference var input = $;var refid = input.attr;var field = $; //Setup the clear of Errmsg//Monitor the change event on ID element, remove error message //of Real inputfield.change{ //Hidden inputvar hinput = $;//real inputvar rinput = $.first();form.data.reset;};

/*** File upload function ,the following attribute to control action of upload* 'endpoint' as upload url* 'sid' as session id* 'complete' optional to configure the custom upload complete function*/var genericUpload = function{var endpointurl = $.attr;var sid = $;var completeFunc = 'uploadComplete';//Setup custome complete functionvar cusComplete = $.attr;if{completeFunc = cusComplete;}

if{delete post_data[k];}else{post_data[k] = v;}form.data('post_data',post_data);return true;};

/*** Generic Ajax Checkbox* The default action is prevented and submit real request through URL*/var ajax_checkbox = function(){event.preventDefault();var action = $;var url = action.attr;var _check = action.prop;console.log;var op ; if{op = "1";}else{op = "0";}$.get(url + op ,function{if{if{action.prop;}else{action.prop;}return true;}else{return false;}},'json');};

var block = l.attr;if{ajaxAutoUnblock = false;}

/*** Lookup new value for hidden value*/var parent_lookup = function(){var lookup = $;var pid = opener.$("#" + lookup.attr;if{alert+ " not found");return false;}var pname = opener.$( "#" + lookup.attr;if{alert+ " not found");return false;}

// create Error data if not present, and add error class for input// "msg.el" data is linked to error message Dom Elementif { //msg = $.addClass.insertAfter;msg = $.addClass.appendTo;input.data;}

msg.css({ visibility: 'visible'}) .fadeIn; msg.parent().addClass;};

/*** Bool Checkbox is special checkbox which needs to keep UNCHECK value * And post with ajax form ,the form is in the parent*/var bool_checkbox = function;var formEle = ipt.closest;var _check = ipt.prop{ajax_update_post_data(formEle,ipt.attr;}else{ajax_update_post_data(formEle,ipt.attr;}};

spin.spin;return true;};

ipt.timePicker;return true;};

// clear the container msg.css({visibility: 'hidden'}).find;

// get handle to the error containervar msg = input.data;

/*** Setup readonly checkbox */var readonlyCheck = function;return false;};

$.ready {$.ajaxStart{//Clean up the Ajax request Page Level Error$.text;//Clean up teh Form Error$.text;//Blocking all ajax processingif{$.blockUI({ message:"{__;}});$.ajaxStop{if{if.data == 1){if{$.unblockUI();}else{ ajaxAutoUnblock = true;}}}else{//Change back to default Synchronized mode from AsyncajaxAutoUnblock = true;ajaxSynchronized = true;}});$.ajaxError(function(event, request, settings){alert('Ajax Request Error! URL='+settings.url);if{if.data == 1){if{$.unblockUI();}else{ ajaxAutoUnblock = true;}}}else{ajaxAutoUnblock = true;ajaxSynchronized = true;}});

// populate messages$.each(error.messages, function.html;

var data_equals_澳门金莎娱乐网站 ,validate = function {var field;var name = input.attr;field = this.getInputs().filter("[name=" + name + "]");return input.val ? true : [name];};

本文由澳门金莎娱乐网站发布于服务器,转载请注明出处:澳门金莎娱乐网站:javascript处理表单示例_基础知

关键词:

最近一段时间的一些学习,EasyUI实现二级页面的

EasyUI,在增、删的时候,经常用到二级页面进行勾选。 EasyUI实现二级页面的内容勾选的方法  在使用EasyUI的时候,我...

详细>>

使用requestAnimationFrame做动画效果一,Javascript动画

假设有这样一个动画功能需求:把一个div的宽度从100px变化到200px。写出来的代码可能是这样的:复制代码 代码如下...

详细>>

选择器演示代码_jquery_脚本之家澳门金莎娱乐网站

[Ctrl+A 全选 注:如需引进外界Js需刷新技术实行] style for display none's div 档次选拔器准则如下: 全然演示代码: class 为...

详细>>

兼容IE与firefox火狐的回车事件,jQuery事件之键盘

代码一:keypress事件时使用 复制代码代码如下:/****************************************************///功能:过滤非法字符 //说明:...

详细>>