Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/10/2012, 13:42
itroyac
 
Fecha de Ingreso: octubre-2012
Ubicación: chiclayo
Mensajes: 3
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: validaciones de RUC en Javascript que acepte máximo 11 números.

hola yo tengo este script que valida solo numeros:
Código:
<script type="text/javascript">
function IsNum( numstr ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;
	var isValid = true;
	var decCount = 0;		// number of decimal points in the string
	// convert to a string for performing string comparisons.
	numstr += "";	
	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special cases for negative numbers (first char == '-')
	// and a single decimal point (any one char in string == '.').   
	for (i = 0; i < numstr.length; i++) {
		// track number of decimal points
		if (numstr.charAt(i) == ".")
			decCount++;
    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || 
				(numstr.charAt(i) == "-") || (numstr.charAt(i) == "."))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) ||
				(numstr.charAt(i) == "." && numstr.length == 1) ||
			  (numstr.charAt(i) == "." && decCount > 1)) {
       	isValid = false;
       	break;
      }         	         	       
//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
   } // END for   
   
   	return isValid;
}  // end IsNum
</SCRIPT>
Pero lo que quiero saber es que entre los 11 numeros solo acepte los que contengan 10 o 20 en el inicio y 6 o 0 al final ejemplo:

10454446546
10345467656
20564321230
20435678910

y que si escriben asi:

13345467654
22564321230
27564321231
09564321236

salga mensaje de numero incorrecto, gracias