help with validate remote
Hi,
I tried to use validate plugin's remote parameter to check for email duplicate, but it always output the message no matter what I do.
This is my html code
- <input class="required email" name="email" id="email"><br/>
my ajax
- $("#signupForm").validate
- ({
- rules:
- {
- email:
- {
- remote:
- {
- url: "<?php echo base_url();?>index.php/register/emailchecker",
- type: "post"
- }
- },
- messages:
- {
- email:
- {
- remote: "Email already exists"
- }
- }
- });
and here is my php code
- function emailchecker()
- {
- $email = strtolower($this->input->post('email'));
- $q = $this->MClients->getemail();
-
- foreach ($q as $key=>$list)
- {
- if ($email == strtolower($list['Email']))
- {
- $valid = false;
- }
- else
- {
- $valid = true;
- }
- }
- echo $valid;
- }
Where did I do wrong?
Thanks