I am using CodeIgniter. I am using jquery remote method to identify the email id already register or not. I tried some code it's working but my doubt is how to display the validation error message on view page?
I am getting the output on the network tab.
Note: I am not talking about the PHP. I know the process will be same but in my case, There error message not displaying on the view page.
HTML
<input type="email" class="form_control" id="email" name="email" value="<?php echo set_value('email'); ?>">
jquery validation
email: {
required: true,
email:true,
remote: {
url: baseUrl + "/Employee_control/checkemail_exist",
type: "post",
data: {
email: function () {
return $("#email").val();
}}
}
},
I already added
messages: {
email: {remote: "This email is already registered with us!"
}
},
Controller
public function checkemail_exist(){
$email= $this->input->post('email');
$email_check=$this->Employee_model->checkemail($email);
if ($email_check == 0) {
//echo "not exist";
return true;
}
else{
//echo " exist";
return false;
}
}
Model
public function checkemail($email){
$this->db->select('email_id');
$this->db->where('email_id',$email);
$query = $this->db->get('tbl_employee');
$result=$query->result();
if (empty($result)) {
return 0;
}
else{
return 1;
}
}