Using JS, a dynamic block is created, part of the code:

divtest.innerHTML = '<div class="blockname">'+ '<form action="" method="post">'+ 'Дата рождения'+ '<input type="text" name="birthday[]" id="birthday" class="form-control" data-mask="00/00/0000" placeholder="__/__/____">'+ '</form>'+ '</div>'; 

Blocks are created, but the mask does not work in them, if you take this code separately on the page (not dynamically), then everything already works in it. What could be wrong? Screenshot of the work of the same code with the usual embedding and adding dynamic through the button

  • Try to contact id. - doox911

1 answer 1

  $('#test').append('<div class="blockname">'+ '<form action="" method="post">'+ 'Дата рождения'+ '<input type="text" name="birthday[]" id="birthday" class="form-control" data-mask="00/00/0000" placeholder="__/__/____">'+ '</form>'+'</div>' ) 
  • It does not work, the problem seems to be in something else, added a photo to make it clearer - nameisusselesinfo
  • Do you need to have slashes when entering? - Maxim Kerimov
  • Yes, in the photo the very first example, how it should be - nameisusselesinfo
  • This matter is not in placeholder, but you need to handle the onchange event of the input and form it - Maxim Kerimov
  • more precisely onkeypress - Maxim Kerimov