Load module: form.js
Serialize
Serialize () ⇒string
Compiles the value of the form element used as a submission into a URL-encoded string in an AJAX POST request. Serializearray
Serializearray () ⇒array
Compiles the value of the form element used as a submission into an array that has a name and value object. Cannot use form elements, buttons, unchecked radio Buttons/checkboxs will be skipped. The result does not contain data for file inputs.
$(‘form‘).serializeArray()//=> [{ name: ‘size‘, value: ‘micro‘ },// { name: ‘name‘, value: ‘Zepto‘ }]
Submit
Submit () ⇒self Submit (function (e) {...}) ⇒self
Bind a handler function for the "submit" event, or trigger the "submit" event on the element. When there is no given function parameter, the current form "Submit" event is triggered and the default commit form behavior is executed, unless Preventdefault () is called.
When given a function parameter, it is simple to bind a handler function for its "submit" event on the current element.
// 触发当前表单“submit”事件,并且执行默认的提交表单行为$("#btn").on(‘click‘, function () { // 触发当前表单“submit”事件,并且执行默认的提交表单行为 $(‘form‘).submit();});
$(‘form‘).submit(function (e) { // 表单验证等操作... if (true) { return false; }});
zepto.js-form Methods