php - Email-Address-Validation using jQuery Validation Plugin's remote method -
i've got problem coding email-address validation on webpage.
the first step, checking if input someone@somewhere.tld works. second check, if email exists in database, not seem work @ all.
i'm using jquery validation plugin.
this code far:
extract register.php:
<form action="addkunde.php" id="contact-form" method ="post" class="form-horizontal"> <div class="control-group"> <label class="control-label" for="email">e-mail-addresse</label> <div class="controls"> <input type="text" class="input-xlarge" name="email" id="email"> </div> </div> <script src="js/jquery.min.js"></script> <script src="js/jquery.validate.js"></script> <script src="script.js"></script> extract script.js:
$(document).ready(function(){ $('#contact-form').validate({ rules: { email: { maxlength: 100, required: true, email: true, remote: { url : "check.php", type : "post" } } }, highlight: function(element) { $(element).closest('.control-group').removeclass('success').addclass('error'); }, success: function(element) { $(element).addclass('valid').closest('.control-group').removeclass('error').addclass('success'); } }); }); extract check.php:
<?php include('mysql.php'); $email = trim(strtolower($_post['email'])); $email = mysqli_real_escape_string($con, $username); $result = mysqli_query($con, "select * kunde email = '$email' limit 1;"); $num = mysqli_num_rows($result); if($num == 0){ echo "true"; } else { echo "e-mail-adresse schon registriert."; } mysqli_close($con); ?> i've been googling hours now, following kinds of different instructions , trying implement own validation method using jquery-validation's addmethod.
i hope can me.
thanks lot!
perhaps string "e-mail-adresse schon registriert." evaluating true success check. can try changing "false" , see if makes difference?
Comments
Post a Comment