在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:macek/jquery-serialize-object开源软件地址:https://github.com/macek/jquery-serialize-object开源编程语言:JavaScript 97.7%开源软件介绍:jQuery Serialize ObjectAs seen on StackOverflow: Convert forms to JSON LIKE A BOSS. Adds the method The current implementation relies in This means it will serialize the inputs that are supported by
Installationoption 1: NPM $ npm install form-serializer option 2: Bower $ bower install jquery-serialize-object option 3: Manual Copy the You can include the plugin in the <head>
<script src="jquery.min.js"></script>
<script src="jquery.serialize-object.min.js"></script>
</head> 2.0Version 2.0 takes jquery-serialize-object into maturity. It is now backed by a full test suite so you can be confident that it will work in your web app. Moving ahead, on top of core serialization, Look forward to these Update: APIGiven a basic HTML form <form id="contact">
<input name="user[email]" value="[email protected]">
<input name="user[pets][]" type="checkbox" value="cat" checked>
<input name="user[pets][]" type="checkbox" value="dog" checked>
<input name="user[pets][]" type="checkbox" value="bird">
<input type="submit">
</form> .serializeObject — serializes the selected form into a JavaScript object $('form#contact').serializeObject();
//=> {user: {email: "[email protected]", pets: ["cat", "dog"]}} .serializeJSON — serializes the selected form into JSON $('form#contact').serializeJSON();
//=> '{"user":{"email":"[email protected]","pets":["cat","dog"]}}' FormSerializer.patterns — modify the patterns used to match field names Many of you have requested to allow Hyphen example $.extend(FormSerializer.patterns, {
validate: /^[a-z][a-z0-9_-]*(?:\[(?:\d*|[a-z0-9_-]+)\])*$/i,
key: /[a-z0-9_-]+|(?=\[\])/gi,
named: /^[a-z0-9_-]+$/i
}); Dot-notation example $.extend(FormSerializer.patterns, {
validate: /^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+)*(?:\[\])?$/i
}); Validating and Key parsing
Key styles
TestsIf you have node.js installed, as a convenience, you can run $ npm test If you do not have node installed, simply $ open ./test/test.html CoffeeScriptCoffeeScript has been dropped for If you'd like to use the the ContributingSee : CONTRIBUTING |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论