Latest web development tutorials
×

jQuery EasyUI Tutorial

jQuery EasyUI Tutorial jQuery EasyUI Introduction

jEasyUI application

jEasyUI Create a CRUD application jEasyUI Create a CRUD data grid jEasyUI Form CRUD application jEasyUI Create an RSS reader

jEasyUI Drag and drop

jEasyUI Basic drag and drop jEasyUI Create a drag-and-drop shopping cart jEasyUI Create a school curriculum

jEasyUI Menus and buttons

jEasyUI Create a simple menu jEasyUI Create a link button jEasyUI Create a menu button jEasyUI Create a split button

jEasyUI layout

jEasyUI Create a border layout jEasyUI Create a complex layout jEasyUI Creates a fold panel jEasyUI Create a tab page jEasyUI Dynamically add a tab jEasyUI Add the AutoPlay tab jEasyUI Create the XP style left panel

jEasyUI Data grid

jEasyUI Convert HTML tables to data grids jEasyUI Get the selected row data jEasyUI Add the query function jEasyUI Add a toolbar jEasyUI Create complex toolbars jEasyUI Sets the frozen column jEasyUI Dynamically change columns jEasyUI Format the column jEasyUI Set sort jEasyUI Custom sorting jEasyUI Create a column combination jEasyUI Add a check box jEasyUI Custom tab jEasyUI Enable in-line editing jEasyUI Extension editor jEasyUI Column operation jEasyUI Merge Cells jEasyUI Create a custom view jEasyUI Create a footer summary jEasyUI Condition Sets the line background color jEasyUI Create an attribute grid jEasyUI The extended line shows the details jEasyUI Create a subgrid jEasyUI Display massive data jEasyUI Add a paging component

jEasyUI window

jEasyUI Create a simple window jEasyUI Customize the Window Toolbar jEasyUI Window and layout jEasyUI Create a dialog box jEasyUI Customize the dialog box

jEasyUI Tree menu

jEasyUI Use the markup to create a tree menu jEasyUI Create an asynchronous tree menu jEasyUI Tree menu to add nodes jEasyUI Create a tree menu with check boxes jEasyUI Tree menu drag and drop control jEasyUI The Tree menu loads the parent / child nodes jEasyUI Create the base tree grid jEasyUI Create a complex tree grid jEasyUI Dynamic loading of tree jEasyUI The tree grid adds pagination jEasyUI Tree-lazy lazy-loading node

jEasyUI Form

jEasyUI Create an asynchronous submission form jEasyUI Form validation jEasyUI Create a tree drop-down box jEasyUI Format the drop-down box jEasyUI Filter down the data grid

jEasyUI Reference Manual

jQuery EasyUI Plugin jQuery EasyUI Extended

jQuery EasyUI form plugin - Form Form

jQuery EasyUI plugin jQuery EasyUI plugin

By $ .fn.form.defaults override the default defaults.

Form (form) offers several ways to perform an action with form fields, such as ajax submit, load, remove, and so on. When submitting a form, call the 'validate' method to check the form is valid.

usage

Create a simple HTML form. Build a form and give id, action, method assignments.

<Form id = "ff" method = "post">
    <Div>
		<Label for = "name"> Name: </ label>
		<Input class = "easyui-validatebox" type = "text" name = "name" data-options = "required: true" />
    </ Div>
    <Div>
		<Label for = "email"> Email: </ label>
		<Input class = "easyui-validatebox" type = "text" name = "email" data-options = "validType: 'email'" />
    </ Div>
    ...
</ Form>

Let the form (form) become ajax form submission (form)

$ ( '# Ff'). Form ({
    url: ...,
    onSubmit: function () {
		// Do some check
		// Return false to prevent submit;
    },
    success: function (data) {
		alert (data)
    }
});
// Submit the form
. $ ( '# Ff') submit ();

Do a submission action

// Call 'submit' method of form plugin to submit the form
$ ( '# Ff'). Form ( 'submit', {
    url: ...,
    onSubmit: function () {
		// Do some check
		// Return false to prevent submit;
    },
    success: function (data) {
		alert (data)
    }
});

By submitting additional parameters

$ ( '# Ff'). Form ( 'submit', {
    url: ...,
    onSubmit: function (param) {
		param.p1 = 'value1';
		param.p2 = 'value2';
    }
});

Submit Response Processing

Submit a ajax form (form) is very simple. When submitting a completed user can obtain the response data. Note that the response data is the raw data from the server. Analytical data for response action requesting the correct data.

For example, assume that the response is JSON data format, a typical response data are as follows:

{
    "Success": true,
    "Message": "Message sent successfully."
}

Now handles JSON string 'success' callback function.

$ ( '# Ff'). Form ( 'submit', {
    success: function (data) {
		var data = eval ( '(' + data + ')'); // change the JSON string to javascript object
		if (data.success) {
			alert (data.message)
		}
    }
});

Attributes

名称 类型 描述 默认值
url string 要提交的表单动作 URL。 null

event

名称 参数 描述
onSubmit param 提交前触发,返回 false 来阻止提交动作。
success data 当表单提交成功时触发。
onBeforeLoad param 发出请求加载数据之前触发。返回 false 就取消这个动作。
onLoadSuccess data 当表单数据加载时触发。
onLoadError none 加载表单数据时发生某些错误的时候触发。

method

名称 参数 描述
submit options 做提交动作,options 参数是一个对象,它包含下列属性:
url:动作的 URL
onSubmit:提交之前的回调函数
success:提交成功之后的回调函数

下面的实例演示如何提交一个有效表单,避免重复提交表单。
$.messager.progress();	// display the progress bar
$('#ff').form('submit', {
	url: ...,
	onSubmit: function(){
		var isValid = $(this).form('validate');
		if (!isValid){
			$.messager.progress('close');	// hide progress bar while the form is invalid
		}
		return isValid;	// return false will stop the form submission
	},
	success: function(){
		$.messager.progress('close');	// hide progress bar while submit successfully
	}
});
load data 加载记录来填充表单。data 参数可以是一个字符串或者对象类型,字符串作为一个远程 URL,否则作为一个本地记录。

代码实例:
$('#ff').form('load','get_data.php');	// load from URL

$('#ff').form('load',{
	name:'name2',
	email:'[email protected]',
	subject:'subject2',
	message:'message2',
	language:5
});
clear none 清除表单数据。
reset none 重置表单数据。该方法自版本 1.3.2 起可用。
validate none 进行表单字段验证,当全部字段都有效时返回 true 。该方法和 validatebox 插件一起使用。
enableValidation none 启用验证。该方法自版本 1.3.4 起可用。
disableValidation none 禁用验证。该方法自版本 1.3.4 起可用。

jQuery EasyUI plugin jQuery EasyUI plugin