Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Rozbicie nr rachunku bankowego
ktuvok
post
Post #1





Grupa: Zarejestrowani
Postów: 243
Pomógł: 0
Dołączył: 30.11.2003

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


Juzer wpisuje w formularzu numer rachunku bankowego bez jakichkolwiek spacji, np:

65106000070000400003256371

W jaki sposób automatycznie wstawić spacje w odpowiednie miejsca stringu, czyli uzyskać postać:

65 1060 0007 0000 4000 0325 6371

?

I drugie pytanie - czy jest sposób, aby wykonać to natychmiast po opuszczeniu przez kursor pola formularza, w którym juzer wpisuje ten numer?

Pozdrawiam,
K
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Paul
post
Post #2





Grupa: Zarejestrowani
Postów: 636
Pomógł: 0
Dołączył: 22.10.2003
Skąd: Katowice

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


  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
  3. <script type="text/javascript">
  4. function formatuj(obj,co_ile){
  5. obj.old = obj.value;
  6. eval('obj.value = strrev(strrev(obj.value).replace(/(.{'+co_ile+'})/g, "$1 "));');
  7. }
  8. function formatuj2(obj){
  9. if(obj.old){
  10. obj.value = obj.old;
  11. }
  12. }
  13. function strrev(str){
  14. return str.split('').reverse().join('');
  15. }
  16. </head>
  17. <input type="text" onfocus="formatuj2(this)" onblur="formatuj(this,4)" size="50">
  18. </form>
  19. </body>
  20. </html>


edit: zmienilem na this, zeby nie trzeba potem juz nic robic (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował Paul 17.07.2004, 08:30:53
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: 24.12.2025 - 08:57