Input Agka saja + Angka 0 didepan tidak boleh


Karena da yang nanya, “bagaimana kalau inputannya gak boleh 0 (nol) duluan gmn mas?

Maka saya coba untuk cari filter input karakter dengan javascript dan menambahi beberapa perintah agar karakter 0 (nol) tidak boleh ditampilkan terlebih dahulu sebelum ada karakter 1 s/d 9

here’s the code : folow this link

[sourcecode]

<!– Begin Code –>

<HTML>
<HEAD>
<SCRIPT language=Javascript>
<!–
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
if (form.txtChar.value.length < 1) {
//alert(“Tidak boleh 0 dulu”);
if (charCode == 48)
return false;
}
return true;
}
//–>
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION=”” name=”form”>
<INPUT id=”txtChar” onkeypress=”return isNumberKey(event)” type=”text” name=”txtChar”>
</FORM>
</BODY>
</HTML>

<!– End Code –>

[/sourcecode]

About blackphp

All about programming php, ajax, jquery, mysql, etc, tips n trick. Now, i'm concern in php programming with codeigniter framework n also training my design skill with photoshop or corel... wish me luck! ('o')

Posted on November 1, 2009, in JavaScript and tagged . Bookmark the permalink. 4 Comments.

  1. Bisaan si udin euy…

  2. cool abis, thx

  3. Ingin belajr lebih giat untuk menngetahui progam ini

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: