Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wstawienie znaku '-' podczas wpisywania w pole tekstowe
wojtek1904
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 8.11.2016

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


Siema, potrzebuje aby po wpisaniu w pole tekstowe po 3 wprowadzonych znakach pojawiał się "-", potem po kolejnych trzech znowu. Niestety coś nie za bardzo mi idzie dzisiaj szukanie odpowiedzi u wujka Google, więc może ktoś wie czy jest jakaś prosta funkcja w phpie lub js?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Neutral
post
Post #2





Grupa: Zarejestrowani
Postów: 286
Pomógł: 46
Dołączył: 10.01.2016

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


  1. <textarea id="text"></textarea>


Kod
var text = document.getElementById('text');
var counter= 1;
var counter2 = 0;

    function append_character(){
         console.log(counter);
        if(counter==3) {
         counter = 0;
         }else{
             null;
        }
      counter2++;
      if(counter2==1){
          null;
      }else{
             if(counter==1){
                text.value =  text.value+'-';
        
             }else{
                text.value =  text.value;
             }
      }
      delete counter2;
        counter +=1;
        
    }


text.addEventListener('keypress',append_character,false);


http://forum.komputerswiat.pl/topic/143266...-pola-textarea/

Ten post edytował Neutral 15.09.2017, 16:02:37
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: 6.10.2025 - 02:59