Mostrando entradas con la etiqueta campo RFC CRM. Mostrar todas las entradas
Mostrando entradas con la etiqueta campo RFC CRM. Mostrar todas las entradas

sábado, 11 de febrero de 2012

Validación de RFC , CRM



function validaRFC(cual)
{
mensaje = "Debes poner un formato LLLL-999999-XXX"
pat = /[a-z]|[A-Z]/
pat2 = /[a-z]|[A-Z]|[0-9]/
val = cual.split("-")
if (val.length == 3){
if(val[0].length == 4){
if(!comp(val[0],pat)){
alert( mensaje)
return false
}
}
if(val[1].length == 6){
if(isNaN(val[1])){
alert('no es un numero')
return false
}
}
if(val[2].length == 3){
if(!comp(val[2],pat2)){
alert(mensaje)
return false
}
}
else{
alert(mensaje)
return false
}
}
else{
alert(mensaje)
return false
}
return true
}


function comp(cual,pa){
for ( m = 0 ; m < cual.length ; m++ ) {
if(!pa.test(cual.charAt(m))){
return false
break
}
}
return true
}