Auto Copy Text From One Field To Another – jQuery Plugin To autofill

Autofill is a fast, easy and useful jQuery plugin that automatically copy and fill out text input fields from another text input fields. Useful to prevent from having to fill out the form twice or more.

How to use it:

1. Load the jQuery javascript library and jQuery autofill plugin in the page.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.autofill.js"></script>

2. Html

<label for="fname">Firstname</label>
<input id="fname" name="fname" type="text"/>
 
<label for="lname">Lastname</label>
<input id="lname" name="lname" type="text"/>
 
<label for="cemail">E-Mail</label>
<input id="cemail" type="text" name="cemail"/>
 
<input id="firstname" name="firstname" type="text" />
<label>Filled first time.</label>
 
<label for="lastname">Lastname</label>
<input id="lastname" name="lastname" type="text" />
<label>Filled first time.</label>
 
<label for="uemail">E-Mail</label>
<input id="uemail" type="text" name="uemail"/>

Call the plugin after DOM ready.

<script>
$().ready(function() {
$("#fname").autofill({
fieldId : "firstname",
overrideFieldEverytime : false
});
         
$("#lname").autofill({
fieldId : "lastname",
overrideFieldEverytime : false
});
 
$("#cemail").autofill({
fieldId : "uemail",
overrideFieldEverytime : true
});
 
});
</script>

 

Please follow and like us:



Leave a Comment

Your email address will not be published. Required fields are marked *