Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/03/2010, 11:22
igonfil
 
Fecha de Ingreso: junio-2008
Mensajes: 250
Antigüedad: 16 años, 5 meses
Puntos: 1
Validar un DNI

Hola a tod@s. Estoy intentando crear una validación de un formulario con javascript pero me da una serie de errores si me podeis ayudar os lo agradecería.
El codigo que tengo es:
Código PHP:

<script language="JavaScript">

function 
verificarfacturacion (){
    
    
numero =document.formulario.txtdomicilio.value;
    
let dni.substr(dni.length-1,1);
    
numero numero 23;
    
letra='TRWAGMYFPDXBNJZSQVHLCKET';
    
letra=letra.substring(numero,numero+1);
    
    if (
document.formulario.txtnombre.value == ""){
        
document.formulario.txtnombre.focus();
        
alert("Introduce el nombre o razón social ");
        }
    
        else{
            if (
document.formulario.txtdomicilio.value==""){
                
document.formulario.txtdomicilio.focus();
                
alert("Introduce el domicilio:.");
                }
                else{
                    if (
document.formulario.txtcp.value==""){
                        
document.formulario.txtcp.focus();
                        
alert("Introduce el código postal");
                        }
                        else{
                            if (
document.formulario.txtlocalidad.value==""){
                                
document.formulario.txtlocalidad.focus();
                                
alert("Introduce la localidad");
                                }
                                else{
                                    if( !/^
d{10}[A-Z]{2}$/.test(document.datos.txtcif.value)) {
                                      
document.formulario.txtcif.focus();
                                    
alert("Introduce el CIF");
                                    }

                                        else{    
                                    if (
document.formulario.txtcif.value==""){
                                        
document.formulario.txtcif.focus();
                                        
alert("Introduce el CIF/NIF");
                                        }
                                        else{
                                    
                                    if (
document.formulario.txtcfactura.value==""){
                                        
document.formulario.txtcfactura.focus();
                                        
alert("Introduce el concepto factura");
                                        }
                                        else{
                                    if (
document.formulario.txtbimpon.value==""){
                                        
document.formulario.txtbimpon.focus();
                                        
alert("Introduce la base imponible ");
                                        }
                                        else{
                                    if (
letra!=let){ 
                                        
alert('Dni erroneo');
                                        }
                                        
                                        
                                else{
                return (
true);
                                }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        
        
    return (
false);

}
                

</script> 
y el formulario es:
Código PHP:
    <form action="facturaprueb2.asp" name="formulario" method="post" onSubmit="return verificarfacturacion ();">
    
    <
br>        
        <
table align="center">
                  <!--
DWLayoutTable-->
                    <
tr>
                        <
td class="texto">Nombre o Razón Social:*</td>
                        <
td>
                            <
input type="text" name="txtnombre" class="input" style="width:200">
                        </
td>
                    </
tr>
                    
                    <
tr>
                        <
td class="texto">Domicilio:*</td>
                        <
td>
                            <
input type="text" name="txtdomicilio" class="input" style="width:200">
                        </
td>
                    </
tr>
                    <
tr>
                        <
td class="texto">Código Postal:*</td>
                        <
td>
                            <
input type="text" name="txtcp" class="input" style="width:200">
                        </
td>
                    </
tr>
                    <
tr>
                        <
td class="texto">Localidad:*</td>
                        <
td>
                            <
input type="text" name="txtlocalidad" class="input" style="width:200">
                        </
td>
                    </
tr>
                    <
tr>
                        <
td class="texto">Provincia:</td>
                        <
td>
                            <
select name="txtprovincia" class="select" style="width:200">
                                <
option selected="selected" value="0">Provincia</option>                        
                                <
option value="Álava">Álava</option>
                                <
option value="Albacete">Albacete</option>
                                <
option value="Alicante">Alicante</option>
                                <
option value="Almería">Almería</option>
                                <
option value="Asturias">Asturias</option>
                                <
option value="Ávila">Ávila</option>
                                <
option value="Badajoz">Badajoz</option>
                                <
option value="Barcelona">Barcelona</option>
                                <
option value="Burgos">Burgos</option>
                                <
option value="Cáceres">Cáceres</option>
                                <
option value="Cádiz">Cádiz</option>
                                <
option value="Cantabria">Cantabria</option>
                                <
option value="Castellón">Castellón</option>
                                <
option value="Ciudad Real">Ciudad Real</option>
                                <
option value="Córdoba">Córdoba</option>
                                <
option value="La Coruña">La Coruña</option>
                                <
option value="Cuenca">Cuenca</option>
                                <
option value="Gerona">Gerona</option>
                                <
option value="Granada">Granada</option>
                                <
option value="Guadalajara">Guadalajara</option>
                                <
option value="Guipúzcoa">Guipúzcoa</option>
                                <
option value="Huelva">Huelva</option>
                                <
option value="Huesca">Huesca</option>
                                <
option value="Islas Baleares">Islas Baleares</option>
                                <
option value="Jaén">Jaén</option>
                                <
option value="León">León</option>
                                <
option value="Lérida">Lérida</option>
                                <
option value="Lugo">Lugo</option>
                                <
option value="Madrid">Madrid</option>
                                <
option value="Málaga">Málaga</option>
                                <
option value="Murcia">Murcia</option>
                                <
option value="Navarra">Navarra</option>
                                <
option value="Orense">Orense</option>
                                <
option value="Palencia">Palencia</option>
                                <
option value="Las Palmas">Las Palmas</option>
                                <
option value="Pontevedra">Pontevedra</option>
                                <
option value="La Rioja">La Rioja</option>
                                <
option value="Salamanca">Salamanca</option>
                                <
option value="Segovia">Segovia</option>
                                <
option value="Sevilla">Sevilla</option>
                                <
option value="Soria">Soria</option>
                                <
option value="Tarragona">Tarragona</option>
                                <
option value="Santa Cruz de Tenerife">Santa Cruz de Tenerife</option>
                                <
option value="Teruel">Teruel</option>
                                <
option value="Toledo">Toledo</option>
                                <
option value="Valencia">Valencia</option>
                                <
option value="Vizcaya">Vizcaya</option>
                                <
option value="Zamora">Zamora</option>
                                <
option value="Zaragoza">Zaragoza</option>                                
                            </
select>
                        </
td>
                    </
tr>
                    <
tr>
                        <
td class="texto">CIF/NIF:*</td>
                        <
td>
                            <
input type="text" name="txtcif" class="input" style="width:200" maxlength="9">
                        </
td>
                    </
tr>
                    <
tr>
                        <
td class="texto" colspan="2">Concepto Factura:*</td>
                    </
tr>
                    <
tr>
                        <
td colspan="2">
                            <
textarea name="txtcfactura" cols="50" rows="10" class="mytextarea" style="width:340"></textarea>

                        </
td>
                    </
tr>
                    <
tr>
                        <
td class="texto">Base imponible * </td>
                        <
td>
                            <
input type="text" name="txtbimpon" class="input" style="width:200">
                        </
td>
                    </
tr>
                    <
tr>
                        <
td colspan="2" align="center">
                            <
input type="submit" value="Enviar" name="btnAceptar" class="input">
                        </
td>
                    </
tr>
        </
table>
            
    
</
form