vendredi 20 juillet 2018

JS Regex Pattern dont work

I'm using this method to validate the time in format: HH:MM-HH:MM

But I always receive false.

This is the method:

var cadena="22:40";
    var patron=/^(0[1-9]|1\d|2[0-3]):([0-5]\d)+-+(0[1-9]|1\d|2[0-3]):([0-5]\d)$/;
      if (patron.test(cadena))
        alert('Correcto');
      else
        alert('Incorrecto');

How can I solve it?

Thanks :)

Aucun commentaire:

Enregistrer un commentaire