[SOLVED] Using "sweetalert2" to confirm "save" data |
3/20/2024 10:40:38 AM |
PHPRunner Tips and Tricks | |
D
DRCR Dev author
Refering to this article: https://asprunner.com/forums/forumreplies_list.php?mastertable=forumtopics&masterkey1=29701&orderby=acreated Hi The example works beautifully, but my question is. If the normal save button does not save because all the field have not been selected, how do we STOP the Sweet Alert and allow the user to correct the errors. Edit Page below: This is the First Part of the Tri Part Button. Swal.fire({ |
|
![]() |
fhumanes 3/20/2024 |
Hello DRCR Dev: When the "Save" button is pressed, PHPRUNNER launches the validations at JavaScript level. In this example, that validation is done when it is executed: $('a[id^="saveButton"]').click(); I do not know how PHPRUNER's function can be executed for JavaScript's validations (I think it is not documented in the JavaScript API). To solve your problem, I think the simple thing is to validate that all mandatory fields are completed and then execute the alert. Greetings, |
D
|
DRCR Dev author 3/20/2024 |
To work around needing the popup, I made the long update run by CLI in the background. I would love to know the answer, because I love the Sweet Alert UI and would love to impliment it site wide for the rare times the server is a little slow. I love the user experience of feeding back to users. Thank you for your reply, I havnt found the code either to work around, but it would great to know for other parts of my site. fhumanes thank you so much for all your tutorials - I have used so much in my work. You are a wonderful human and helped me very very much. Bless you for your kindness. |
C
|
cristi 3/20/2024 |
You can use two methods from sweet alert 2: showValidationMessage and resetValidationMessage for this - I think. something like if ($("#field").val() === "") { then reset and display the succes message. |
![]() |
fhumanes 3/21/2024 |
Hello DRCR dev, I have already seen how validations can be done before executing the "alert". This is the code that I put to validate the fields "text1" and "number1". /* Validation field */ Manual : https://xlinesoft.com/phprunner/docs/ctrl_validate.htm I will modify my article with these changes. Greetings, |
D
|
DRCR Dev author 3/21/2024 |
Hi fhumanes Thanks! That makes so much sense. Its the parts controlled by PHPRUNNER that confuse me, Thank you, I saved this code to my good code list. |