Support the ongoing development of Laravel.io →
Requests Forms
Last updated 2 years ago.
0

With that setup, have you considered using some jquery validation? That way when you leave a field, user can get a notice right away if field isn't properly filled in. Also set it up so form can't be submitted until validation passes on all fields. Of course always have a cancel button that redirects user to a page of your choice.
Google for jquery / javascript form validation.
Here's one: http://jqueryvalidation.org/ and docs http://jqueryvalidation.org/documentation/

0

jimgwhit said:

With that setup, have you considered using some jquery validation? That way when you leave a field, user can get a notice right away if field isn't properly filled in. Also set it up so form can't be submitted until validation passes on all fields. Of course always have a cancel button that redirects user to a page of your choice.
Google for jquery / javascript form validation.
Here's one: http://jqueryvalidation.org/ and docs http://jqueryvalidation.org/documentation/

So I do have jquery validation set up on the form. I should have mentioned that. And it prevents submitting the forum until all things are filled in properly.

But I've always been under the impression to NEVER leave form validation to jquery/javascript alone. To always have server side.

And yeah, I guess I could say, go ahead and put in the server side validation, and if someone is actively bypassing the jquery validation, the server side will catch it. And then too bad for them, since they bypassed jquery validation, they don't get the form reloaded with their updated date.

And honestly, that's where I'm at now. And I can handle that.

But I also feel like the 'right' way to do it, is both. Keep my jquery validation. And then have server side checks that redirect you to the form WITH the data if you fail.

.....

In terms of accopmlishing that, my best thoughts thus far. Are to store page1 'filter' data into the session. Then store page2 form data in a session as well when submitted. Then if validation fails, don't do a redirect->back. But instead resubmit the form with the page1 filtering information. Then load the form with the values from the database. Then, finally, change those values to the updated values from the stored session the user just submitted but failed validation on. And then display any errors regarding the failed validation.

Does anyone have any better ideas? That seems like a lot of work, and I feel there should be a better way.

0

You can use jQuery AJAX leave everything filled in and just check it on server with jQuery AJAX. Have a controller routine that checks all the data. Might be a little hard at first to set up but well worth it once its all done. In essence it will be like a dummy post where you are just verifying the data.

Last updated 9 years ago.
0

jimgwhit said:

You can use jQuery AJAX leave everything filled in and just check it on server with jQuery AJAX. Have a controller routine that checks all the data. Might be a little hard at first to set up but well worth it once its all done. In essence it will be like a dummy post where you are just verifying the data.

Yeah that's not a bad way to do it either. And probably not much more work than the way I was thinking of doing it. I may give that a try. Have AJAX try to validate. If it passes, then submit. If it doesn't, just leave them there and return a message.

I guess I was hoping for an easier solution. But this is doable.

0

You could even have jquery put a temporary label above the field to let user know validation is incorrect. If you are new to jquery, jream has some excellent tuts on YouTube. Good luck with project.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Nertskull nertskull Joined 3 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.