Codeigniter Tutorial: How To check Username/Email availablity using jQuery in Codeigniter?

This post is for CI lover who wants to learn Codeigniter. This script will show you how can we check live availability of username or email using Ajax in Codeigniter. Using this tutorial you can also understand how can we send a jQuery Ajax request to server living in CI.

In your view where you have created form include jQuery library and put the below code there.
In header section:

In body section in your form:

Ajax Indicator

In Your controller add this function:

Suppose you have a model called my_model.php and a table tbl_members or what ever you named. This table should have a field named “email” of type varchar [200].
Add this function:

That’s it, this function will return a message against email field that whether it is available or not. This is not for only email, you can use it to check any field. Also this is client side check so you also need to use this model function in server side so that email can also be verified when form has been submitted with disabling javascript .

Comments are closed.