NotionCommotion Posted January 4, 2015 Share Posted January 4, 2015 I have a form on a user input page in an application which requires JavaScript. Please keep whether one should require JavaScript off the table. I have two possible workflows: Option 1 Display form either with no filled in inputs if it is a new entry, or existing data from the database should it be an edit. Upon submit, validate the page client side and if okay post the data via Ajax. Server validates the data, saves data if no errors, and returns an array with any errors. Client alerts (probably with an alert statement) user of any errors and if none redirects client side to the next appropriate page. Option 2 Display form either with no filled in inputs if it is a new entry, or existing data from the database should it be an edit. Upon submit, validate the page client side and if okay submits the form. Server validates the data. If no errors, saves the data and redirects to the next appropriate page. If errors, redisplay the page with appropriate errors and makes previous user inputs sticky. I previously went with Option 1, but started to think it was a bit of a kludge. Sure is easy to implement, however. Are there any other recommended workflows? Is one of these two options better than the other? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/293659-validation-workflow/ Share on other sites More sharing options...
QuickOldCar Posted January 5, 2015 Share Posted January 5, 2015 If really want to do form validation is a lot can implement using html5 and show error messages right there. Instead of an alert if fails server validation can display a message via ajax in a divider. Can even go so far to only show a submit button if passes your form validation. I want to say have a "call a friend" feature being a smartass, depends how complicated want to get with a simple form. Quote Link to comment https://forums.phpfreaks.com/topic/293659-validation-workflow/#findComment-1501812 Share on other sites More sharing options...
NotionCommotion Posted January 5, 2015 Author Share Posted January 5, 2015 Hi quickoldcar, I am using the jQuery validation plugin, so most if not all of the errors are caught before going serverside, and show a message next to the field. I never looked into html5 validation before, but just did at http://www.the-art-of-web.com/html/html5-form-validation/. Wow, not much need to implement a preliminary JS validation strategy any more, is there? You think most user's browsers support nowadays? Not sure I understand the "call a friend" feature. Quote Link to comment https://forums.phpfreaks.com/topic/293659-validation-workflow/#findComment-1501814 Share on other sites More sharing options...
QuickOldCar Posted January 5, 2015 Share Posted January 5, 2015 Call a friend was a Who Wants to Be a Millionaire joke. Meaning if it gets too confusing call someone for help. I believe all modern browsers support it now, older IE always has issues, I wish people would stop using it. Quote Link to comment https://forums.phpfreaks.com/topic/293659-validation-workflow/#findComment-1501819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.