Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JS] problem z walidacją
zeta758
post 6.09.2007, 10:25:00
Post #1





Grupa: Zarejestrowani
Postów: 74
Pomógł: 0
Dołączył: 18.06.2006

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


mam cos takiego w JS:
  1. ['validate-date', 'Please use this date format: dd-mm-yyyy. For example 17-03-2006 for the 17th of March, 2006.', function(v) {
  2. if(Validation.get('IsEmpty').test(v)) return true;
  3. var regex = /^(\d{2})\-(\d{2})\-(\d{4})$/;
  4. if(!regex.test(v)) return false;
  5. var d = new Date(v.replace(regex, '$2/$1/$3'));
  6. return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) &&
  7. (parseInt(RegExp.$1, 10) == d.getDate()) &&
  8. (parseInt(RegExp.$3, 10) == d.getFullYear() );
  9. }],


dziala dla formatu daty: 22-12-1988

ja chce zeby dzialalo dla formatu 1988-12-22

zmienilem na:
  1. ['validate-date', 'Please use this date format: dd-mm-yyyy. For example 17-03-2006 for the 17th of March, 2006.', function(v) {
  2. if(Validation.get('IsEmpty').test(v)) return true;
  3. var regex = /^(\d{4})\-(\d{2})\-(\d{2})$/;
  4. if(!regex.test(v)) return false;
  5. var d = new Date(v.replace(regex, '$3/$1/$2'));
  6. return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) &&
  7. (parseInt(RegExp.$1, 10) == d.getDate()) &&
  8. (parseInt(RegExp.$3, 10) == d.getFullYear() );
  9. }],

ale to nie pomoglo sad.gif
Go to the top of the page
+Quote Post
gekon
post 6.09.2007, 13:04:16
Post #2





Grupa: Zarejestrowani
Postów: 614
Pomógł: 7
Dołączył: 10.11.2003
Skąd: Rzeszów/Kraków

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


  1. ['validate-date', 'Please use this date format: dd-mm-yyyy. For example 17-03-2006 for the 17th of March, 2006.', function(v) {
  2. if(Validation.get('IsEmpty').test(v)) return true;
  3. var regex = /^(\d{4})\-(\d{2})\-(\d{2})$/;
  4. if(!regex.test(v)) return false;
  5. var d = new Date(v.replace(regex, '$3/$1/$2'));
  6. return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) &&
  7. (parseInt(RegExp.$3, 10) == d.getDate()) &&
  8. (parseInt(RegExp.$1, 10) == d.getFullYear() );
  9. }],


--------------------
Pokaż kod = Pokaż CAŁY kod, najlepiej działający na jakimś serwerze.
Fanatycy | glazar.info | semantyka | HTML i XHTML FAQ
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 24.07.2025 - 20:08