So I have a joomla! page that is partly generated by functions based on the user. So parts of the forms that I need to use the 'masked input plug-in' on are loaded via functions on page load. The issue I have is, on the fields that are standard HTML on the page, the plugin works fine but on the fields that are generated by my php functions, the fields lock up and don't allow any input. My guess is that it's an issue with the php functions pulling in the forms after the jquery plugin has fired but I tried placing the .mask call in a $(document).ready and no luck.
here's a snippet...
jQuery(function($){
$("#subNumber").mask("(999) 999-9999");
$(".numFix").mask("(999) 999-9999");
});
THIS WORKS -->
<form name = "subAct" id = "subAct" method="post">
<div class="col1"><input class="subaccountname" name="subName" type="text" id="subName"/></div>
<div class="col2"><input class="subaccountnumber" name="subNumber" type="text" id = "subNumber"/></div>
<div class="col3"><a href="javascript:submit()" class="buttonaddsub" id ="addSubBut">Add a New Account</a></div>
</form>
THIS ONE DOESN'T --> this function -->
<?php dashboardFunction::displaySubAccount($uid) ?>
loads in this form -->
<form name = "add_reg_num_<?php echo $pin ?>" id = "add_reg_num_<?php echo $pin ?>" method="post">
<div class="regisnumberadd"><input name="regNum" type="text" class = "numFix" />
<input name="regNumPin" type="hidden" value = "<?php echo $pin ?>"/>
</div>
<div class="clear"></div>
<div class="addregisnum"><a href="javascript:;" onClick="subRegNum(<?php echo $pin ?>)">Add Number</a></div>
</form>
All you need to do is attach an event binding using jQuery .on method and any dynamically created item will be wired to that event.
I answered a similar question here https://stackoverflow.com/a/10203361/12442