0

The below alert popup is displayed in case of error and user should stay on the same page in order to modify the content of field. So the task is to have a popup message that when closed, let the user on the same page without reloading it and showing him the values put in the fields.

....

else{
    echo "  
    <script type='text/javascript'>
    alert ('Error Message.'); return false;
    </script>
    ";}

I put the 'return false' in order to avoid to redirect but it doesn'work.

Alex
  • 91
  • 2
  • 10
  • When you post a form in php it always reloads the page. If you didn't want to reload the page then use the ajax to submit the form and then use the result returned through the ajax to show success or the error. – Suhail Akhtar Aug 20 '17 at 12:33
  • I was wondering to put the fields values check on click event instead of php script execution. – Alex Aug 20 '17 at 12:35
  • What do you want to validate? If it is something from server side then you have to use ajax other wise you can validate with js. – Suhail Akhtar Aug 20 '17 at 12:43
  • I am realizing i need of a double validation: 1 - On submit event to check all the fields are filled in; 2 - to check the UPDATE query has no errors. At this point I need to implement case 1 since case 2 is already done redirecting to the index.php page with js above. – Alex Aug 20 '17 at 12:52
  • use beforeSubmit event of form to validate your form fields. – Suhail Akhtar Aug 20 '17 at 13:02
  • yes indeed . How to make the check that all fields in the form are not empty? – Alex Aug 20 '17 at 13:05
  • 1
    try this https://stackoverflow.com/questions/16211871/how-to-check-if-all-inputs-are-not-empty-with-jquery – Suhail Akhtar Aug 20 '17 at 14:12
  • thnsk Suhail, very helpful your link. Going to implement my html. – Alex Aug 20 '17 at 14:49

0 Answers0