Jump to content

Error messages in forms


ckrudelux

Recommended Posts

How do you do then sending messages to the user then some input fields are missing then submiting.Js stoping them from sending.cookies, get, submit script on the same page?Looking for insperation.

Link to comment
Share on other sites

I used to redirect back to the form, with an extra $_GET value in the URL, to tell the page which error message to display, but the problem with that is that you can't auto-refill the values the user already entered.A better way would be to do it would be to require() the page with the form after setting an $error value. On the form page, check to see if $error is set with isset(), and if it is, display the correct error message.

Link to comment
Share on other sites

I used to redirect back to the form, with an extra $_GET value in the URL, to tell the page which error message to display, but the problem with that is that you can't auto-refill the values the user already entered.A better way would be to do it would be to require() the page with the form after setting an $error value. On the form page, check to see if $error is set with isset(), and if it is, display the correct error message.
if you submit the form to itself, the $_GET/$_POST variables will be available to the page. for a truly responsive form, I would have basic JS validation per 'important' form field doing validation onblur. I would also validate the form before allowing the submit event to go all the way through. Have the form redirect to itself, and it will pass all the form values 'back' to itself. From there, you can do any server side validation you need before sending the data where you want it to go. If there are any problems, you are still on the form page so you can re-populate the form fields with the user inputted data. Or, if everything clears and the form submission was successful, you can either prevent the form from displaying and display a success message, or redirect them to a success page.
Link to comment
Share on other sites

if you submit the form to itself, the $_GET/$_POST variables will be available to the page. for a truly responsive form, I would have basic JS validation per 'important' form field doing validation onblur. I would also validate the form before allowing the submit event to go all the way through. Have the form redirect to itself, and it will pass all the form values 'back' to itself. From there, you can do any server side validation you need before sending the data where you want it to go. If there are any problems, you are still on the form page so you can re-populate the form fields with the user inputted data. Or, if everything clears and the form submission was successful, you can either prevent the form from displaying and display a success message, or redirect them to a success page.
Kind of what I was thinking about... but are there others known methods trying to get a picture of what my options are.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...