hello...
i am doing registration form .in this without submit form can i get alert box....email already exists using javascript. can any body tell me.


thnks.

If you google "javascript alert" you will find many examples of how to create a javascript alert box.

Your algorithm should follow these steps:
1. Get the entered email address from the form.
2. Validate the email address has a valid format.
3. Use SQL statement to see if the email address exists in your database.
4. Display an error message in an alert if the email does exist.

If you google "javascript alert" you will find many examples of how to create a javascript alert box.

Your algorithm should follow these steps:
1. Get the entered email address from the form.
2. Validate the email address has a valid format.
3. Use SQL statement to see if the email address exists in your database.
4. Display an error message in an alert if the email does exist.

i am using like this ...but it is not working.

email=window.document.create_profile.email.value;
var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;
if(email== "")
{	
	alert("Please enter Email Id.");
	window.document.create_profile.email.focus();
	return false;
		
}

if(email!= "")
{	
	var eres=email.search(emailFormat);
	if(eres == -1)
	{
		alert("Please Enter Valid Email Id ");
		window.document.create_profile.email.select();
		return false;
	}
	else
	{
	
	<?
	$selectemail=mysql_query("select * from workseeker_registration");
	while($fetchemail=mysql_fetch_array($selectemail))
	{
	
	?>
	
var existemail=<?=$fetchemail['email']?>;

	if(email==existemail)
	{
	alert("This email already exists");
		window.document.create_profile.email.select();
		return false;
		}
	<?
	}
	?>
	}
}
else
{
return true;
}
Member Avatar for rajarajan2017

Check with google whether gotFocus and lostFocus available for textboxes, if it is, then you can call your javascript code on lostfocus to avoid the submit button validate.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.