Currently, I am in the process of creating a form that includes a text box. One important validation I need to implement is that the name entered must be unique.
My approach involves accessing the parent div and modifying the entire HTML content within it.
Specifically, I am targeting the parent div and executing the following:
parentdiv.find('.child').html('<div class="form-group has-error has-feedback validateblockname"> <input type="hidden" id = "edit_tower_id" ><div class="alert alert-danger blocknamealert" role="alert" style="margin: 5px 0px 0px 0px;float: right; padding: 0;"> <code style="font-size: small;">Tower name already exists </code></div></input><label for="ProjectBlocks_block_name" class="control-label">Name</label><span class="glyphicon glyphicon-exclamation-sign form-control-feedback"></span><input type="text" class="form-control" id="ProjectBlocks_block_name" onblur="EditProjectBlocks.validateblockname();" onchange="EditProjectBlocks.validateblockname();"></div>'')
https://i.sstatic.net/ieiPY.png https://i.sstatic.net/n6Mwp.png
This snippet is related to the initial image display.
parentdiv.find('.child').html('<div class="form-group"><input type="hidden" id="edit_tower_id"><label for="ProjectBlocks_block_name" class="control-label">Name</label><input type="text" class="form-control" id="ProjectBlocks_block_name" onblur="EditProjectBlocks.validateblockname();" onchange="EditProjectBlocks.validateblockname();"></div>');
Is there a more efficient alternative to achieve this task?