justinh Posted December 26, 2014 Share Posted December 26, 2014 Hi, I'm using ASP web pages with a PHP server-side script to process a form with method=post. I'm checking the validity of a field in the PHP script, and if it fails there is code in the PHP to pop a message dialog (via javascript). The current workflow is this: 1) user submits form with bad data 2) simultaneously, a dialog is popped saying there is an error, and the form web page is gone and a blank page is shown 3) user selects the OK button and a javascript "history.go(-1)" is executed 4) user is now back to the form with previous values in the fields If the user put in good data, he would be advanced to a 'thank you' page. I'd like to avoid (2) and (3) with the page advancing then going back. In other words, I'd like the error check and message to be processed before the form page is left. Is what I want possible? Note that I can't modify the PHP much, and I'm very green at programming. :-) Thanks, Justin Link to comment Share on other sites More sharing options...
niche Posted December 26, 2014 Share Posted December 26, 2014 (edited) If you're depending on php, you'll have to leave the page. Else, there's javascript. Can you use js? EDIT: This might help http://stackoverflow.com/questions/20537696/remember-and-repopulate-file-input Edited December 26, 2014 by niche Link to comment Share on other sites More sharing options...
justinh Posted December 28, 2014 Author Share Posted December 28, 2014 Yes, I have to use the PHP script. I see other pages with PHP (I'm pretty sure) form validation that will give user feedback on the page (showing red text and such) with no apparent page transition - it looks like real-time validation. How do they do that? Is the page actually being refreshed and I just can't tell it? Link to comment Share on other sites More sharing options...
Ingolme Posted December 28, 2014 Share Posted December 28, 2014 Yes, I have to use the PHP script. I see other pages with PHP (I'm pretty sure) form validation that will give user feedback on the page (showing red text and such) with no apparent page transition - it looks like real-time validation. How do they do that? Is the page actually being refreshed and I just can't tell it? They're using Javascript to validate the form. Sometimes purely with Javascript, other times they'll use AJAX to ask for database information from PHP Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now