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édia vá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á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édia:/label>";
inner += "<input type=\"text\" size \"4\" class=\"conceito\" name=\"conceito["+numerodematricula+"]\" value=\""+conceito+"\">";
c.innerHTML = inner;
dfinalizar();
}
</script>