Jump to content

Recommended Posts

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

  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.
  2. Upon submit, validate the page client side and if okay post the data via Ajax.
  3. Server validates the data, saves data if no errors, and returns an array with any errors.
  4. Client alerts (probably with an alert statement) user of any errors and if none redirects client side to the next appropriate page.

 

Option 2

  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.
  2. Upon submit, validate the page client side and if okay submits the form.
  3. 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

Link to comment
https://forums.phpfreaks.com/topic/293659-validation-workflow/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/293659-validation-workflow/#findComment-1501812
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/293659-validation-workflow/#findComment-1501814
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/293659-validation-workflow/#findComment-1501819
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.