Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/06/2007, 03:20
tammander
 
Fecha de Ingreso: enero-2006
Ubicación: Torroles (Costa der Só)
Mensajes: 1.017
Antigüedad: 19 años, 3 meses
Puntos: 7
Re: Validar campo de form a formato especifico

En ASP VBScript yo lo haria asi:

Código:
function validaFormato(texto)
    validaFormato = false
    if len(texto) <> 13 then exit function

    ' Comprobar 4 primeros caracteres [1 - 4] --> Deben ser Letras    
    for n = 1 to 4
        if isnumeric(mid(texto,n,1)) then exit function 
    next
    
    ' Siguientes 6 [5-10] --> Numericos
    for n = 5 to 10
        if not isnumeric(mid(texto,n,1)) then exit function 
    next
    
    ' Siguiente [11] Numero
    if not isnumeric(mid(texto,11,1)) then exit function 
    
    ' Siguiente [12] Letra
    if isnumeric(mid(texto,12,1)) then exit function 
    
    ' Siguiente [13] Numero
    if not isnumeric(mid(texto,13,1)) then exit function 
    
    validaFormato = true
end function

Un saludo
__________________
"Tus pecados son el estiércol sobre el que florecerán las flores de tus virtudes" - Gerald Messadié -