Hi,
I am using jquery easyui validatebox for validating data in my form. However, in one of the forms, there is scope to create a group of form elements dynamically by clicking 'add elements' button.
<fieldset id="teacher_2">
<legend style="display: none">Teacher Details</legend>
<div id="tchentry1" class="clonedInputTch">
<h2 id="reference_tch" name="reference_tch" class="heading-reference">Detail #1</h2>
<div class="form-group">
<input type="text" name="tch_fname[]" class="form-control easyui-validatebox" placeholder="First name" data-options="required:true"/>
</div>
<div class="form-group">
<input type="text" name="tch_lname[]" class="form-control easyui-validatebox" placeholder="Last name" data-options="required:true"/>
</div>
<div class="form-group">
<input type="text" name="tch_email[]" class="form-control easyui-validatebox" placeholder="Email" data-options="required:true,validType:'email'"/>
</div>
<div class="form-group">
<input type="text" name="tch_userid[]" class="form-control easyui-validatebox" placeholder="User ID" data-options="required:true,validType:'minLength[5]'" />
</div>
</div>
<p class="text-center">
<button type="button" id="btnAddTch" name="btnAddTch" class="btn bg-olive">add teacher</button>
<button type="button" id="btnDelTch" name="btnDelTch" class="btn btn-danger">remove teacher above</button>
</p>
</fieldset>
On clicking the 'add teacher' button, basically I am using jquery .clone() method to create a copy of the div with class 'clonedInputTch'. As you can see, I have used "easyui-validatebox" class for validation of the form elements.
When there is only set of form elements, the validation is working fine. However, once a new set of fields have been generated dynamically, the validation is not working. And at this point getting following error in console:
Uncaught TypeError: Cannot read property 'options' of undefined jquery.easyui.min.js:5943
_43b jquery.easyui.min.js:5943
(anonymous function) jquery.easyui.min.js:5984
x.extend.each jquery.js:590
x.fn.x.each jquery.js:237
$.fn.validatebox.methods.enableValidation jquery.easyui.min.js:5983
$.fn.validatebox jquery.easyui.min.js:5955
(anonymous function) registerParent.php:200
x.event.dispatch jquery.js:4692
y.handle
Please let me know if this functionality is possible. If so, kindly guide on how to implement the same.
Thanks in advance.