Salin kode kode sebagai berikut:
<bahasa skrip = "javascript" type = "text/javascript">
Function check (event) {
// Setiap kali pengguna menekan tombol, dia akan menilai apakah itu angka
if (event.keycode <48 || event.keycode> 57) {{) {{) {{{{{{{{{{{
Window.alert ("Anda tidak memasukkan nomor!");
Mengembalikan false;
}
}
</script>
<body>
<input type = "text" onkeypress = "return check (event)"/>
</body>