Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/02/2015, 14:19
PHPeros
Colaborador
 
Fecha de Ingreso: septiembre-2013
Ubicación: España
Mensajes: 3.648
Antigüedad: 10 años, 8 meses
Puntos: 578
Respuesta: Expresion regular, validar Nota Examen

El que no entiende soy yo

Código Javascript:
Ver original
  1. function validarNota(nota) {
  2.     var formatoNota = /^(10|\d([.,]\d{1,2})?)$/;
  3.     if (formatoNota.test(nota)){
  4.         alert('Nota bien introducida');
  5.     }else{
  6.         alert('Nota mal introducida');
  7.     }
  8. }
  9.  
  10. validarNota(9.25); // Bien
  11. validarNota(20); // Mal
  12. validarNota("5,8") // Bien
  13. validarNota(0.123); // Mal
  14. validarNota(10); // Bien

¿No era eso lo que querías?