Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] problem z value.match
escobar1983
post
Post #1





Grupa: Zarejestrowani
Postów: 198
Pomógł: 0
Dołączył: 31.01.2008

Ostrzeżenie: (0%)
-----


Witam. Robie walidacje numerow telefonow w js i mam taki kod
Kod
if(telefon!='')
    {
        var retel=/^([0-9]{2})+\s*([0-9]{3})+\s*([0-9]{3})+\s*([0-9]{3})+\s*([0-9]{3})$/;
        var tel1=telefon.substr(0,14);
       var check1=tel1.value.match(retel);
if(!check1)
        {
            document.getElementById('eror_tel').innerHTML = '<font color="#ff0000"> 48 123 456 789 </font>';
            blad='tak';
          alert(blad);  
        }

}


Bład jaki sie pokazuje to "tel1.value is undefined"
No i to nie chodzi. Moze ktos mi podpowie co jest nie tak. Z góry dziekuje



Ten post edytował escobar1983 8.11.2009, 20:58:27
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
merk
post
Post #2





Grupa: Zarejestrowani
Postów: 30
Pomógł: 7
Dołączył: 31.05.2006

Ostrzeżenie: (0%)
-----


hej,

zamiast

  1. var check1=tel1.value.match(retel);


wywołaj po prostu metodę match na stringu

  1. var check1=tel1.match(retel);


Ten post edytował merk 8.11.2009, 22:01:10
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 21:15