Home > Client Side Scripting > Email Validasi Dengan Javascript

Email Validasi Dengan Javascript

November 16, 2013 Leave a comment Go to comments

Berikut ini trivia untuk validasi input untuk email menggunakan javascript.

Javascript validation code:

<script language="javascript">
function emailValidation(){
var email = document.getElementById("email").value;
var atpos = email.indexOf("@");
var dotpost = email.lastIndexOf(".");
if( atpos <1 ||  dotpos < atpos+2  || dotpos+2 >= email.length)
alert("Invalid Email Address");
return false;

Form input (.html)

<form method="post" action="" onsubmit="return emailValidation()">
<label for="lbl_email"> Email :</lable> <input type="text" name="email" id="email">
<input type="submit" value="Submit">

Semoga bermanfaat.

  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: