Programmatically creating multivalue field with a button of add another In the field ui, we can create a textfield with unlimited values. Which has button of add another, which when clicked added another field with a remove button.

I want the same functionality in my custom form. How will I create a textfield with unlimited values?
Here is a nice article on how to do it using Form API http://rapiddg.com/blog/use-ajax-support-multiple-item-values-custom-drupal-7-forms

Hope this helps.