Add mask to input
Posted
by
Lodewijk Wensveen
on Stack Overflow
See other posts from Stack Overflow
or by Lodewijk Wensveen
Published on 2013-10-22T09:41:58Z
Indexed on
2013/10/22
9:54 UTC
Read the original article
Hit count: 385
I'm trying to achieve the seemingly impossible task of adding an mask to a input field.
I have the following code:
function addActivationCode(){
newRow = jQuery("div.activationcode:last-child").clone();
newRow.insertAfter(jQuery("div.activationcode:last-child"));
newRow.attr("id", "coderow-" + Math.round(Math.random() * 10000));
newRow.find("input").val("");
find("input").mask("9999-9999-9999-9999");
newRow.find("a.coderemove").attr("onclick", "removeActivationCode('" + newRow.attr("id") + "'); return false;");
}
function removeActivationCode(id){
jQuery("div#" + id).remove();
}
Now I to get the .mask working on my input fields, so far I've only got it working on the new row I'm making and not on the original one.
Can anyone help me out?
© Stack Overflow or respective owner