[eluser]sanks[/eluser]
Hi,
I am facing problems while using jquery validation plugin using codeigniter. The remote method does not process the request. My code for js is as follows:
Code:
$(document).ready(function(){
$("#register").validate({
rules:{
uname: {
required: true,
minlength: 4,
maxlength:12,
remote: {
url: 'user/check',
type: 'post'
}
},
messages: {
uname: {
required: "<br/><label class='errors'>Please enter a username</label>",
minlength: "<br/><label class='errors'>Username must be at least 4 characters long</label>",
maxlength:"<br/><label class='errors'>Username can be only 12 characters long</label>",
remote:jQuery.format("Email \"{0}\" have been used.")
}
}
});
And the code for controller is:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Controller {
function __construct()
{
parent::__construct();
}
function check()
{
$this->load->model('useraccount');
$result = $this->useraccount->check_availability();
if($result)
{
return true;
}
else
{
return false;
}
}
}
?>
code for the check_availability function:
Code:
function check_availability()
{
$fieldname = trim($this->input->post('uname'));
$this->db->select('*');
$this->db->from('account_regd');
$this->db->where('uname',$fieldname);
$query = $this->db->get();
if($query->num_rows() > 0)
{
return false;
}
else
{
return true;
}
}
Can anyone help me with this?