Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML]Chciałbym po przekroczeniu liczby 20 text sie zerował., Tagi: Formularz,wyzerownie liczb,html.
lukaszsss
post
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 30.11.2008

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


Mam taką tabele

Kod
<tr><td>ile:</td> <td><input type="text" name="temat" size="2" maxlength="2"></td></tr>


Teraz chciałbym aby można było tam napisać liczby od 1 do 20 jeśli ktoś napisze np: 21 to w tabeli text sie wyzeruje.

Ten post edytował lukaszsss 17.12.2008, 18:18:59
Go to the top of the page
+Quote Post
Maxik
post
Post #2





Grupa: Zarejestrowani
Postów: 726
Pomógł: 129
Dołączył: 10.01.2008
Skąd: Gdańsk

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


W sekcji head dodaj:
Kod
<script type="text/javascript">
function max(number){
if((number>20)&&(number<1)){
document.getElementById('temat').value = '';
}
}
</script>


A inputa daj tak:
  1. <tr><td>ile:</td> <td><input type="text" name="temat" size="2" maxlength="2" id="temat" onkeyup="max(this.value)"></td></tr>


Pisane z palca
Go to the top of the page
+Quote Post
melkorm
post
Post #3





Grupa: Zarejestrowani
Postów: 1 366
Pomógł: 261
Dołączył: 23.09.2008
Skąd: Bydgoszcz

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


  1. <input type="text" value="" id="box" size="2"/>
  2. <script type="text/javascript">
  3. document.getElementById('box').onkeyup = function() {
  4. if(Number(this.value) >= 21 || Number(this.value) <= 0 || !Number(this.value)){
  5. this.value ="";
  6. }
  7. }


Tutaj jeszcze zerowanie na wpisane nieliczby.
Go to the top of the page
+Quote Post

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: 5.10.2025 - 11:41