Create dynamic textfield? I have a form builder containing the following code.

  $form['finput']['noreff1'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('No Reff1'),
  '#size' =&gt; 60,
  '#default_value' =&gt; $noreff1,
  //'#required' =&gt; TRUE,
  '#autocomplete_path' =&gt;'noreff/autocomplete',
  '#ahah' =&gt; array(
      'event'   =&gt; 'change',
      'path'    =&gt; ahah_helper_path(array('finput')),
      'wrapper' =&gt; 'finput-wrapper',
     'method' =&gt; 'replace',
         'progress' =&gt; 'throbber',
  ),
  '#prefix' =&gt; '&lt;div class="finput-form"&gt;', '#suffix' =&gt; '&lt;/div&gt;',
  );   

  $form['finput']['noreff2'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('No Reff2'),
  '#size' =&gt; 60,
  '#default_value' =&gt; $noreff2,
  //'#required' =&gt; TRUE,
  '#autocomplete_path' =&gt;'noreff/autocomplete',
  '#ahah' =&gt; array(
      'event'   =&gt; 'change',
      'path'    =&gt; ahah_helper_path(array('finput')),
      'wrapper' =&gt; 'finput-wrapper',
     'method' =&gt; 'replace',
         'progress' =&gt; 'throbber',
  ),
  '#prefix' =&gt; '&lt;div class="finput-form"&gt;', '#suffix' =&gt; '&lt;/div&gt;',
  );

  $form['finput']['noreff3'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('No Reff3'),
  '#size' =&gt; 60,
  '#default_value' =&gt; $noreff3,
  //'#required' =&gt; TRUE,
  '#autocomplete_path' =&gt;'noreff/autocomplete',
  '#ahah' =&gt; array(
      'event'   =&gt; 'change',
      'path'    =&gt; ahah_helper_path(array('finput')),
      'wrapper' =&gt; 'finput-wrapper',
     'method' =&gt; 'replace',
         'progress' =&gt; 'throbber',
  ),
  '#prefix' =&gt; '&lt;div class="finput-form"&gt;', '#suffix' =&gt; '&lt;/div&gt;',
  );


This code shows a fixed number of form fields (noreff1, noreff2, noreff3). If I want to dynamically increase those form fields, how can I do?
So, I just want to show one textfield for starting. If user not use
  that form, it doesn't show new form. But, if user input some value in
  that form, when user finish inputing that value (confirm by click
  enter button on keyboard for example), new textfield form showd up so
  user can fill new value, and so on.. – bandungeuy


I don't think there is a Drupal way to do that, but you can always do this with jQuery. 

For example:

HTML

&lt;form&gt;
&lt;div class="form-item" id="edit-first-name-wrapper"&gt;

  First name:&lt;br&gt;
  &lt;input type="text" name="firstname" id="edit-first-name"&gt;&lt;br&gt;

&lt;/div&gt;  


&lt;div class="form-item" id="edit-last-name-wrapper"&gt;

  Last name:&lt;br&gt;
  &lt;input type="text" name="last-name" id="edit-last-name"&gt;

&lt;/div&gt;
&lt;/form&gt;


jQuery

(function ($) {

   $('#edit-last-name-wrapper').hide();

   (function Forever(){ 

     var grabs = $('#edit-first-name').val();

     if (grabs != '') { 
       $('#edit-last-name-wrapper').slideDown(1500); 
     } 
     // slides down and shows the last name field if the first name field is not empty
     else if (grabs == '') { 
     // checks if the first name field is empty  
       $('#edit-last-name').val(''); 
         // empties the last name field, since there is no first name
       $('#edit-last-name-wrapper').slideUp(1500); 
         // slides up and hides the last name field

     }

   setTimeout(Forever, 1);

   })();

})(jQuery);


JS Fiddle DEMO