Ver Mensaje Individual
  #14 (permalink)  
Antiguo 28/09/2011, 14:01
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Problema con validacion Field

veamos si funciona ahora
Cita:
<script language="javascript">
function valida_nueva_ficha(locualo)
{
for(m=0;m<locualo.length;m++)
{
if((locualo[m].type== "file") && (locualo[m].value != ""))
{
if(locualo[m].value.substring(locualo[m].value.length-3,locualo[m].value.length).toLowerCase() != "jpg")
{
alert("Debes insertar sólo archivos de tipo jpg")
return false
break
}
}
else
{
continue
}

}
}









var numero = 0;
*
// Funciones comunes
c= function (tag) { // Crea un elemento
* *return document.createElement(tag);
}
d = function (id) { // Retorna un elemento en base al id
* *return document.getElementById(id);
}
e = function (evt) { // Retorna el evento
* *return (!evt) ? event : evt;
}
f = function (evt) { // Retorna el objeto que genera el evento
* *return evt.srcElement ? *evt.srcElement : evt.target;
}
*
addField = function () {
* * if(numero<9)
* * {
* * * *container = d('files');
* * * *
* * * *span = c('SPAN');
* * * *span.className = 'file';
* * * *span.id = 'file' + (++numero);
* *
* * * *field = c('INPUT'); *
* * * *field.name = 'archivos[]';
* * * *field.type = 'file';
* * * *
* * * *a = c('A');
* * * *a.name = span.id;
* * * *a.href = '#ancla_insert';
* * * *a.onclick = removeField;
* * * *a.className = 'texto_azul_link';
* * * *a.innerHTML = '&laquo; Quitar';
* *
* * * *span.appendChild(field);
* * * *span.appendChild(a);
* * * *container.appendChild(span);
* * }
}
removeField = function (evt) {
* *lnk = f(e(evt));
* *span = d(lnk.name);
* *span.parentNode.removeChild(span);
* *
* *numero--;
}

</script>