I just started learning CodeIgniter. There is a library $this->load->library('form_validation'); for form validation with rules. Does that mean we don't have to use Javascript to validate forms anymore? Because, if we have to use those validators in CI (sake of the best practise), what is the point of using Javascript... Or do I misunderstand the point here?

I know that not using JS puts extra work on server so we should use both JS and CI validation in any cases and also, JS might have been disabled as well. Am I right???

$this->form_validation->set_rules('textEmail', 'Email Address', 'trim|required|min_length[5]|max_length[100]|valid_email');

Thanks in advance

Recommended Answers

All 2 Replies

You should always have server side validation regardless of whether or not you use client side validation. There are so many ways to send bad data to a web page you always want to make sure that it is clean before you process it or use it in any database activities.

Client side validation is really a convienence to the user. The client will always provide quicker feedback to the user, you can notify the user as soon as they exit the field of an invalid entry. Using only server side validation requires the user to wait for there input to be validated on the server.

The difficulty is keeping these vaidation checks in sync.

Then I should always use JS and CI validation in any cases. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.