Acme.BookStore.HttpApi.Host/node_modules/jquery-form/docs/form-fields.md
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
---
---
## Form Fields
This page describes and demonstrates the Form Plugin's `fieldValue` and `fieldSerialize` methods.
### fieldValue
`fieldValue` allows you to retrieve the current value of a field. For example, to retrieve the value of the password field in a form with the id of 'myForm' you would write:
```javascript
var pwd = $('#myForm :password').fieldValue()[0];
```
This method *always* returns an array. If no valid value can be determined the array will be empty, otherwise it will contain one or more values.
### fieldSerialize
`fieldSerialize` allows you to serialize a subset of a form into a query string. This is useful when you need to process only certain fields. For example, to serialize only the text inputs of a form you would write:
```javascript
var queryString = $('#myForm :text').fieldSerialize();
```
<form id="inputForm" action="#">
<div>
<h4>Demonstration</h4>
<p>
Enter a jQuery expression into the textbox below and then click 'Test' to see the results
of the <code class="inline">fieldValue</code> and <code class="inline">fieldSerialize</code>
methods. These methods are run against the test form that follows.
</p>
jQuery expression:
<input id="query" type="text" value=":text">
<span style="color:#555">(ie: textarea, [@type='hidden'], :radio, :checkbox, etc)</span><br>
<input id="successful" type="checkbox" checked="checked"> [Successful controls](https://www.w3.org/TR/html5/forms.html#constructing-form-data-set) only<br>
<input type="submit" value="Test">
</div>
</form>
<form id="test" action="dummy.php" method="post"><div>
<strong>Test Form</strong>
<table>
<tr><td><input type="hidden" <span class="name">name="Hidden"</span> value="secret"></td><td><input type="hidden" name="Hidden" value="secret"></td></tr>
<tr><td><input <span class="name">name="Name"</span> type="text" value="MyName1"></td><td><input name="Name" type="text" value="MyName1"></td></tr>
<tr><td><input <span class="name">name="Password"</span> type="password"></td><td><input name="Password" type="password" value=""></td></tr>
<tr><td><select <span class="name">name="Multiple"</span> multiple="multiple"></td><td><select name="Multiple" multiple="multiple">
<option value="one" selected="selected">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select></td></tr>
<tr><td><select <span class="name">name="Single"</span>></td><td><select name="Single">
<option value="one" selected="selected">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select></td></tr>
<tr><td><input type="checkbox" <span class="name">name="Check"</span> value="1"></td><td><input type="checkbox" name="Check" value="1"></td></tr>
<tr><td><input type="checkbox" <span class="name">name="Check"</span> value="2"></td><td><input type="checkbox" name="Check" value="2"></td></tr>
<tr><td><input type="checkbox" <span class="name">name="Check"</span> value="3"></td><td><input type="checkbox" name="Check" value="3"></td></tr>
<tr><td><input type="checkbox" <span class="name">name="Check2"</span> value="4"></td><td><input type="checkbox" name="Check2" value="4"></td></tr>
<tr><td><input type="checkbox" <span class="name">name="Check2"</span> value="5"></td><td><input type="checkbox" name="Check2" value="5"></td></tr>
后面还有 25 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
