jQuery form validation using CI back-end rules |
[eluser]steelaz[/eluser]
I created solution that does front-end validation using back-end validation rules. No more writing separate validation routines and you get the same native CI validation error messages on front-end. Blog post (how it works) Source code Demo
[eluser]theshiftexchange[/eluser]
I just wanted to come back and /bump this thread - and say thanks again to Steelaz - this is an awesome addon - which has saved me so much time, and greatly improved the logic and cleanness of my website code. Thanks!!
[eluser]CroNiX[/eluser]
I do the same thing except I created a new method in MY_Form_Validation to return the validation error ARRAY ($_error_array), so I can highlight the individual error fields when it gets returned to the ajax callback as a json object. (as opposed to just using validation_errors() which returns a single string with all errors)
[eluser]theshiftexchange[/eluser]
question: has anyone here been able to get this to work when CSRF is turned on? Mine stops working - and I'm not 100% sure how to fix it....
[eluser]theshiftexchange[/eluser]
I needed a quick fix for this - so I decided that a solution would be to "ignore" the CSRF check for the jquery validation calls. There is no (obvious) security risk I can see here, because the validation rules are public knowledge anyway (since we send them as text to the browser). To achieve this, I extended the Security class, and did a check for the "welcome/remote" URI. For me, this is my generic path that all my jquery validation goes to. Just change "welcome/remote" to wherever your remote() function is. Code: <?php If anyone can see any flaws/security issues with this - I'd be keen to hear it...
[eluser]CroNiX[/eluser]
Just pass the CSRF token. Much better than disabling security. |
Welcome Guest, Not a member yet? Register Sign In |