dynamic form

dynamic form

Hello, 

I have written a script that adds rows to a table and creates form fields using Jquery.
Some of these form fields are only supposed to allow numeric data. 

I used in other pages of my site the following piece of code. Those pages are not dynamic though (ie form fields are not added on the fly) and this code works great
  1. //all form element of class 'field4 are numeric
  2. $(".field4").format({precision: 2,autofix:true});


so my question is how do I attach the above piece of code to a form field dynamically created. A sample of my dynamic code is shown below



  1. .append(
  2. $("<td>")
  3. .append(
  4. $("<input/>")
  5. .attr("type","text")
  6. .attr("id", "task_alloc_"+RowCount)
  7. .addClass("field4")
  8. .attr("name", "task_alloc_"+RowCount)
  9. .attr("value", task_data[1])
  10. .attr("maxlength", 10)
  11. )
)

Thanks