Form.php

<form autocomplete="off" enctype="multipart/form-data" method="post"  name="form">

<p></p>
<div class="form-elements-malling">
<label for="fullnamemalling">Name<br /></label>
<input type="text" name="fullnamemalling" id="fullnamemalling"/>
<span></span>
</div>

<p>&nbsp;</p>
<div class="form-elements-malling">
<label for="emailmalling">Email<br /></label>
<input type="text" name="emailmalling" id="emailmalling"/>
<span></span>
<input type="submit" value="Submit" style=" background:#0060a1; color:#FFFFFF; font-size:14px; border:0; " class="submit"/>


<span class="error1" style="display:none"> Please Enter Valid Data</span>
<span class="success" style="display:none"> Registration Successfully..</span>
</div>
</form>

validate.js
Inserting Done No Problem okay .. But i need To Know how Can i do
email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/ ;
i need any ally visitor if write name & e-mail = Code Do 1 check email If mail true do submit If mail false .error = mail not valid ??
2 - i need Code Search in the database - if found the same e-mail error = email already exists and dont send

$(function() {

		   
$(".submit").click(function() {
    var fullnamemalling = $("#fullnamemalling").val();
	var emailmalling = $("#emailmalling").val();
    var dataString = 'fullnamemalling='+ fullnamemalling + '&emailmalling=' + emailmalling;
	
	


	if(fullnamemalling=='' || emailmalling=='')
	{
	
	$('.success').fadeOut(200).hide();
    $('.error1').fadeOut(200).show();
	}
	else
	{

	$.ajax({
	type: "POST",
    url: "./styles/libs/validatemalinglist.php",
    data: dataString,
    success: function(){
	$('.success').fadeIn(200).show();
    $('.error1').fadeOut(200).hide();
   }
		   
   
		   
});
}
return false;
});
});

please help me

I dont have a solution sorry... but put your email input type as email.

<input type="email" name="emailmalling" id="emailmalling"/>

I dont have a solution sorry... but put your email input type as email.

<input type="email" name="emailmalling" id="emailmalling"/>

Sorry I don't have a solution atm, will look at it later, however do not change your text input to email like suggested above, this is html5, and this input type is not supported by IE or Safari.

check this code for email validtion. it works.

function valid_domain_part($domain_part) { 
            if(preg_match("/[^a-zA-Z0-9@#\[\].]/", $domain_part)) { 
                return false; 
            } 
            elseif(preg_match("/[@]/", $domain_part) && preg_match("/[#]/", $domain_part)) { 
                return false; 
            } 
            elseif(preg_match("/[\[]/", $domain_part) || preg_match("/[\]]/", $domain_part)) { 
                $dot_pos = strrpos($domain_part, "."); 
                if(($dot_pos < strrpos($domain_part, "]")) || (strrpos($domain_part, "]") < strrpos($domain_part, "["))) { 
                    return true; 
                } 
                elseif(preg_match("/[^0-9.]/", $domain_part)) { 
                    return false; 
                } 
                else { 
                    return false; 
                } 
            } 
            else { 
                return true; 
            } 
        } 
        // trim() the entered E-Mail 
        $str_trimmed = trim($temp_email); 
        // find the @ position 
        $at_pos = strrpos($str_trimmed, "@"); 
        // find the . position 
        $dot_pos = strrpos($str_trimmed, "."); 
        // this will cut the local part and return it in $local_part 
        $local_part = substr($str_trimmed, 0, $at_pos); 
        // this will cut the domain part and return it in $domain_part 
        $domain_part = substr($str_trimmed, $at_pos); 
        if(!isset($str_trimmed) || is_null($str_trimmed) || empty($str_trimmed) || $str_trimmed == "") { 
          echo  "You must insert something"; 
            return false; 
        } 
        elseif(!valid_local_part($local_part)) { 
            $this->email_status = "Invalid E-Mail Address"; 
            return false; 
        } 
        elseif(!valid_domain_part($domain_part)) { 
            $this->email_status = "Invalid E-Mail Address"; 
            return false; 
        } 
        elseif($at_pos > $dot_pos) { 
            echo "Invalid E-Mail Address"; 
            return false; 
        } 
        elseif(!valid_local_part($local_part)) { 
            echo "Invalid E-Mail Address"; 
            return false; 
        } 
           
		      elseif(($str_trimmed[$at_pos + 1]) == ".")
			   { 
            echo "Invalid E-Mail Address"; 
          
        } 
        elseif(!preg_match("/[(@)]/", $str_trimmed) || !preg_match("/[(.)]/", $str_trimmed)) { 
            echo "Invalid E-Mail Address"; 
         
        } 
        else { 
            
        } 

}

also check bracket m not sure if any got mising during copying.

sorry i missed the starting code. this is the full function code of email validation

function email_valid($temp_email) { 
######## Three functions to HELP ######## 
        function valid_dot_pos($email) { 
            $str_len = strlen($email); 
            for($i=0; $i<$str_len; $i++) { 
                $current_element = $email[$i]; 
                if($current_element == "." && ($email[$i+1] == ".")) { 
                    return false; 
                    break; 
                } 
                else { 

                } 
            } 
            return true; 
        } 
        function valid_local_part($local_part) { 
            if(preg_match("/[^a-zA-Z0-9-_@.!#$%&'*\/+=?^`{\|}~]/", $local_part)) { 
                return false; 
            } 
            else { 
                return true; 
            } 
        } 
        function valid_domain_part($domain_part) { 
            if(preg_match("/[^a-zA-Z0-9@#\[\].]/", $domain_part)) { 
                return false; 
            } 
            elseif(preg_match("/[@]/", $domain_part) && preg_match("/[#]/", $domain_part)) { 
                return false; 
            } 
            elseif(preg_match("/[\[]/", $domain_part) || preg_match("/[\]]/", $domain_part)) { 
                $dot_pos = strrpos($domain_part, "."); 
                if(($dot_pos < strrpos($domain_part, "]")) || (strrpos($domain_part, "]") < strrpos($domain_part, "["))) { 
                    return true; 
                } 
                elseif(preg_match("/[^0-9.]/", $domain_part)) { 
                    return false; 
                } 
                else { 
                    return false; 
                } 
            } 
            else { 
                return true; 
            } 
        } 
        // trim() the entered E-Mail 
        $str_trimmed = trim($temp_email); 
        // find the @ position 
        $at_pos = strrpos($str_trimmed, "@"); 
        // find the . position 
        $dot_pos = strrpos($str_trimmed, "."); 
        // this will cut the local part and return it in $local_part 
        $local_part = substr($str_trimmed, 0, $at_pos); 
        // this will cut the domain part and return it in $domain_part 
        $domain_part = substr($str_trimmed, $at_pos); 
        if(!isset($str_trimmed) || is_null($str_trimmed) || empty($str_trimmed) || $str_trimmed == "") { 
          echo  "You must insert something"; 
            return false; 
        } 
        elseif(!valid_local_part($local_part)) { 
            $this->email_status = "Invalid E-Mail Address"; 
            return false; 
        } 
        elseif(!valid_domain_part($domain_part)) { 
            $this->email_status = "Invalid E-Mail Address"; 
            return false; 
        } 
        elseif($at_pos > $dot_pos) { 
            echo "Invalid E-Mail Address"; 
            return false; 
        } 
        elseif(!valid_local_part($local_part)) { 
            echo "Invalid E-Mail Address"; 
            return false; 
        } 
           
		      elseif(($str_trimmed[$at_pos + 1]) == ".")
			   { 
            echo "Invalid E-Mail Address"; 
          
        } 
        elseif(!preg_match("/[(@)]/", $str_trimmed) || !preg_match("/[(.)]/", $str_trimmed)) { 
            echo "Invalid E-Mail Address"; 
         
        } 
        else { 
            
        } 

}
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.