Que puedo estar haciendo mal.
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jquery Agregar campos</title>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
function validarDinamicos()
{
$(".validar").each(function(){
if( validarEmail($(this).val())){
alert('Email valido');
} else {
alert('Email invalido');
}
});
}
contador=0;
function agregar()
{
contador=contador+1;
//$('#elementos').append('<div id="divelem_' + contador + '" ><table border="0" width="830"><tr><td width="300"><input type="text" name="nombreElemento[]" id="elemento' + contador + '" size="45" value=""/></td><td width="30"><a href="javascript:borrar_campo(' + contador + ')"><img src="../img/eliminar.png" border="0"></a></td></tr></table></div>');
$('#elementos').append('<div id="divelem_' + contador + '" ><table border="0" width="830"><tr><td width="300"><input type="text" name="nombreElemento[]" [B]class="validar" [/B] id="elemento' + contador + '" size="45" value=""/></td><td width="30"><a href="javascript:borrar_campo(' + contador + ')"><img src="../img/eliminar.png" border="0"></a></td></tr></table></div>');
}
function borrar_campo(registro)
{
$("#divelem_" + registro).remove();
i--;
}
$(".validar").each(function(){
if( validarEmail($(this).val())){
alert('Email valido');
} else {
alert('Email invalido');
}
});
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="#">
<div id="elementos">
<table border='0' width="830">
<tr>
<td width="300">Emails</td>
<td width="30"><a href="javascript:agregar()"><img src="../img/create.png" alt="" border="0" /></a></td>
</tr>
</table>
<p>
<input type="submit" name="button" id="button" value="Enviar" onclick="return validarDinamicos()"
/>
</p>
</div>
</form>
</body>
</html>