jQuery mask does not read innerHTML

0

I'm having trouble generating mask reading (jQuery) on elements generated via innerHTML . Only validator works and after trying to insert a data outside the mask it loads the page with the mask.

Here's the mask:

<script> 
$(document).ready( function() {     
     $.validator.addMethod("conceito", function (value, element) { 
     return ((/^((((([1]{1}[0]{1})\,([0]{1}))|((([0]{1})(\d){1}))\,(\d){1}))|([F]{1}))?$/i.test(value))); 
      }, "Digite uma m&eacute;dia v&aacute;lida (valores entre 00,0 e 10,0 ou o conceito F)"); 

      $('.conceito').mask("A9,9"); 
      $('#gerar_conceitos').validate({ 
        // Define as regras 
        errorElement: "em", 
        errorContainer: $(".error"), 
        errorPlacement: function(error, element) { 
          element.parent().append(error); 
        }, 
        success: function(label) { 
          label.text("Sem erros."); 
        }, 
        messages: { 
          conceito: { 
            required: "Digite uma média v&aacute;lida (valores entre 00,0 e 10,0)" 
          } 
        } 
      }); 

});   
</script>

And the innerHTML:

 <script type="text/javascript" language="javascript">            
 function msalterar(numerodematricula,conceito){
        c=document.getElementById('conceito['+numerodematricula+']');
        inner ="<label>M&eacute;dia:/label>";                       
                    inner += "<input type=\"text\" size \"4\" class=\"conceito\" name=\"conceito["+numerodematricula+"]\" value=\""+conceito+"\">";
                    c.innerHTML = inner;
                    dfinalizar();
            }

  </script>
    
asked by anonymous 25.04.2014 / 21:30

1 answer

1

I can not see where you use the function msalterar() and I also do not know what the function dfinalizar() does, but I imagine that after you dynamically generate a input , you should reapply mask % . So try this or something:

   <script type="text/javascript" language="javascript">            
        function msalterar(numerodematricula,conceito){
            c=document.getElementById('conceito['+numerodematricula+']');
            inner ="<label>M&eacute;dia:/label>";                       
                    inner += "<input type=\"text\" size \"4\" class=\"conceito\" name=\"conceito["+numerodematricula+"]\" value=\""+conceito+"\">";
                    c.innerHTML = inner;
                    dfinalizar();

                     $('.conceito').mask("A9,9");
            }
  </script>
    
26.04.2014 / 03:58