Evet bu kod iyi oldu peki şunu nasıl yapabilirim. Kutucukların degerleri birbirinden farklı olursa,
input1 alanı mesela şifre : 3 karekter sınırı olacak
input2 alanı telefon no: 7 karekter sınırı olacak
<script language="javascript">
var nereye='quantity';
function tusGir(tus){
if (document.getElementById(nereye).value.length >= document.getElementById(nereye).getAttribute('maxlength'))
{
alert("En fazla "+ document.getElementById(nereye).getAttribute('maxlength') + " karakter girebilirsiniz.");
}
else
{
document.getElementById(nereye).value = document.getElementById(nereye).value + tus;
}
}
</script></head>
<body>
<form action="" method="post" class="" name="numPad">
<table cellpadding="2" cellspacing="2" border="0" width="44">
<tr>
<td colspan="3" align="center">
<p align="right">Şifreniz
<input id="quantity" type="text" name="quantity" size="10" maxlength="5" onfocus="nereye='quantity';"></td>
</tr>
<tr>
<td colspan="3" align="center">
<p align="right">cep no
<input id="quantity1" type="text" name="quantity1" size="10" maxlength="7" onfocus="nereye='quantity1';"></td>
</tr>
<tr>
<td><input type="button" value=" 1 " onclick = "tusGir('1');"></td>
<td><input type="Button" value=" 2 " onclick = "tusGir('2');"></td>
<td><input type="Button" value=" 3 " onclick = "tusGir('3');"></td>
</tr>
<tr>
<td><input type="Button" value=" 4 " onclick = "tusGir('4');"></td>
<td><input type="Button" value=" 5 " onclick = "tusGir('5');"></td>
<td><input type="Button" value=" 6 " onclick = "tusGir('6');"></td>
</tr>
<tr>
<td><input type="Button" value=" 7 " onclick = "tusGir('7');"></td>
<td><input type="Button" value=" 8 " onclick = "tusGir('8');"></td>
<td><input type="Button" value=" 9 " onclick = "tusGir('9');"></td>
</tr>
<tr>
<td colspan="3">
<p align="center">
<input type="button" value=" 0 " onclick = "tusGir('0');"></td>
</tr>
</table>
</form>