![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
10/07/2015, 13:46
|
![Avatar de nolose](http://static.forosdelweb.com/customavatars/avatar208761_1.gif) | | | Fecha de Ingreso: diciembre-2007 Ubicación: España
Mensajes: 165
Antigüedad: 17 años, 1 mes 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;
} |