Welcome Guest, Not a member yet? Register   Sign In
Checking email Availability
#1

[eluser]Noah_Igniter[/eluser]
Code:
// Jquery function

$(document).ready(function() {
    /// make loader hidden in start
    $('#Loading').hide();    

    $('#email').blur(function(){
var a = $("#email").val();
var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
       // check if email is valid
if(filter.test(a)){
                // show loader
  $('#Loading').show();
  $.post("<?php echo base_url()?>controller_name/check_email_availablity", {
   email: $('#email').val()
  }, function(response){
                        //#emailInfo is a span which will show you message
   $('#Loading').hide();
   setTimeout("finishAjax('Loading', '"+escape(response)+"')", 400);
  });
  return false;
}
});
function finishAjax(id, response){
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}

// controller
function check_email_availablity()
  {
$this->load->model('User_Model');
$get_result = $this->User_Model->check_email_availablity();

if(!$get_result )
echo '<span>Email already in use. </span>';
else
echo '<span>Email Available</span>';
  }

// model
function check_email_availablity()
{
        $email = trim($this->input->post('email'));
$email = strtolower($email);

$query = $this->db->query('SELECT * FROM sn_members where email_address="'.$email.'"');

if($query->num_rows() > 0)
return false;
else
return true;
}

not working please help me...thank you
#2

[eluser]jurlan[/eluser]
What exactly isn't working? Maybe give some more info on the error message?
#3

[eluser]Noah_Igniter[/eluser]
//my view
Code:
<label>Email id</label>
&lt;input type="text" name="email_address" class="email" value="&lt;?php echo set_value('lastname',$this-&gt;input-&gt;post('email_address')); ?&gt;" /&gt;
<span id="Loading"><img src="&lt;?php echo base_url(); ?&gt;/images/ajaxloader.gif" alt="Delete" border="0"/></span>

i already using the jquery validate plugin....aditionally i add the "email availability code' at buttom of my form in script tag......when i placed, the very next moment, entire validation(i.e jquery plugin not working)..


/////finally iam new to CI, i need email availability function
#4

[eluser]CroNiX[/eluser]
I can see this causing an error if the form hadn't been submitted yet:
Code:
&lt;?php echo set_value('lastname',$this->input->post('email_address')); ?&gt;

Code:
set_value($field_name, $default_value);
You are setting the $default_value to a POST value, which won't be available until the form has been submitted so that is probably causing an error on initial page load. Are you not displaying errors?

$default_value is what the value should be when the page first loads, or leave it off to be an empty string.

Also, it seems you are mixing the 'lastname' and 'email_address' fields there. When it first loads you are saying you want it to be the email_address value, and then if they submit it you are saying it should be the lastname field value.
#5

[eluser]Noah_Igniter[/eluser]
Thank you.......




Theme © iAndrew 2016 - Forum software by © MyBB