This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Senin, 25 Juli 2011

Membuat validasi email dengan vb



Ketika iseng-iseng buka vb . Eh keingat gimana ya membuat validasi email. Akhirnya muter-muter deh di internet . Dan akhirnya nemu juga . Ini dia script untuk mengecek email di textbox valid atau nggak.





Silahkan kopi code dibawah ini :


Function IsEmail(ByVal Str As String) As Boolean
Set r = CreateObject("VBScript.RegExp")
r.IgnoreCase = True
r.Pattern = "^[\w-\.]+@\w+\.\w+$"
IsEmail = r.Test(Str)
End Function


Dari Function tersebut akan bernilai True atau False. Untuk penerapan di vb nya tinggal Ketikan code berikut di textbox tertentu:


Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If IsEmail(Me.Text1.Text) = False Then
MsgBox "Salah"
Else
MsgBox "Benar"
End If
End If
End Sub



Terima Kasih Semoga bermanfaat koding sederhana ini

Kamis, 24 Februari 2011

Textbox Hanya Bisa Diisi Angka dengan JavaScript

Bagaimana ya agar textbox bisa diisi angka saja. Mungkin anda akan bertanya-tanya bagaimana membuatnya. Jadi ketika kita mengetikkan huruf maka tidak akan tampil di dalam textbox tersebut. Namun jika di ketik angka maka textbox akan terisi dengan angka saja.

Pada prinsipnya kita akan mendeteksi keycode dari tombol keyboard yang kita tekan . Jadi ketika kita menekan tombol keyboard , itu dinamakan event keypress , jika dalam dalam code htmlnya adalah onkeypress. Ketika menekan tombol keyboard maka akan membawa yang namanya event. dan itulah yang nanti kita gunakan untuk mendeteksi keycode dari tombol tersebut.

Berikut contoh code untuk membatasi textbox agar bisa diisi angka saja :

<html>
<head>
<title>HOME</title>
<script language="javascript">
function angka(evt)
{
var e = event || evt;
var charCode = e.which || e.keyCode;

if (charCode > 31 || (charCode <> 57))
return false;

return true;

}
</script>
</head>
<body>
<input type="text" name="jumlah" onkeypress="return angka(event);">
</body>
</html>


Selamat mencoba . Semoga bermanfaat .. Terima Kasih