Skip to content
Advertisement

Codeigniter 3: Don’t reload form on form validation error

I’m new with codeigniter. I have this form and in the end of the form the user have to re-enter his password for confirmation, however, the page reloads if the password was incorrect and all the data that the user typed on the input field disappeared. Is there a way for the validation_error to output without the page reloading?

Here’s my view form SHIFTER.HTML

JavaScript

Here’s the controller

JavaScript

And here’s the model

JavaScript

Advertisement

Answer

The page is reloading before the server even performs the validation. You’ll need to use AJAX. AJAX the request. On failed validation, have the AJAX callback pop a message to the user. On successful validation, have the AJAX callback direct the user to the desired page.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement