jQuery Plugin To Auto Fill Form Elements From Preset Data - Form Autofill
| File Size: | 3.53 KB |
|---|---|
| Views Total: | 7325 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
An useful jQuery plugin which allows you to autofill form elements (inputs, textarea, checkboxes, selects, etc.) from preset data defined in the javascript.
Basic usage:
1. Load the jQuery javascript library and jQuery form autofill plugin at the end of the document.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="jquery.formautofill.js"></script>
2. Create form elements with the required name attributes.
<form role="form" id="demo"> <input type="text" placeholder="User Name" name="name"> <input type="email" placeholder="Email" name="email"> <textarea name="textarea"></textarea> ... </form>
3. Create an button to autofill the form elements.
<input type="button" class="autofill-button" value="Autofill">
4. Define the data in the javascript and bind the click event on the button to perform the autofill action.
<script>
var data = {
"name": "jQuery Script",
"email": "[email protected]",
"textarea": "jQueryscript.net - free jQuery plugins",
}
$(".autofill-button").bind("click", function() {
$("#demo").autofill(data);
});
</script>
This awesome jQuery plugin is developed by creative-area. For more Advanced Usages, please check the demo page or visit the official website.











