Ver Mensaje Individual
  #8 (permalink)  
Antiguo 10/07/2015, 13:46
Avatar de nolose
nolose
 
Fecha de Ingreso: diciembre-2007
Ubicación: España
Mensajes: 165
Antigüedad: 16 años, 3 meses
Puntos: 2
Respuesta: Validación de campos numéricos POSITIVOS y con 3 decimales...

Posteo una nueva respuesta, porque sólo he encontrado este POST y me ha costado encontrar un a solución:

Aplicando esta expresión regular funciona:

^[1-9]\d{0,2}(\.\d{3})*(,\d+)?$

i.e. this is a digit in the range 1-9 followed by up to 2 other digits then zero or more groups of a full stop followed by 3 digits then optionally your comma and digits as before.


Ejemplo:

if((/^[1-9]\d{0,2}(\.\d{3})*(,\d+)?$/).exec(document.f1.consumo.value)==null){
$bool_error = false;
}
else{
$bool_error = true;
}