phemi Posted February 21, 2009 Share Posted February 21, 2009 Hi everyone, i have a form of which i want an error dialogue box to display when a visitor/user does not fill a field properly or doesn't enter any value at all. whereby when the user click the submit button it displays a dialogue box saying "sorry! you have not enter any e-mail address". The one i have presently, when the submit button is clicked loads and go "processing" page to display the message. But now i want it to echo it directly on the same page with a dialogue box. Thanks Link to comment https://forums.phpfreaks.com/topic/146230-displaying-an-error-dialog-box/ Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 Move all the processing script up to the top of the page that the form is on. Then change the 'action' of the <form> tag to be the same page as the form is on. Now your processing is on that page, and you can output your errors on the same page. Link to comment https://forums.phpfreaks.com/topic/146230-displaying-an-error-dialog-box/#findComment-767706 Share on other sites More sharing options...
Dtonlinegames Posted February 21, 2009 Share Posted February 21, 2009 You could validate the fields before posting them at all using Javascript function validate(){ if(document.formname.elementname.value =null){ document.error dialogue box.innerHTML ='Element Name is Empty!'; } else if(document.formname.elementname2.value =null){ document.error dialogue box.innerHTML ='Element Name2 is Empty!'; } else{ document.formname.submit(); } } And just add all your elements, you could try using for each or do while with it but I gave you a quick example saves server load times and the user doesnt have to wait for the page to reload Link to comment https://forums.phpfreaks.com/topic/146230-displaying-an-error-dialog-box/#findComment-767731 Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 Thats true, except that it doesn't work for users who have javascript turned off, so it should be combined with a server-side solution anyways. Link to comment https://forums.phpfreaks.com/topic/146230-displaying-an-error-dialog-box/#findComment-767736 Share on other sites More sharing options...
Dtonlinegames Posted February 21, 2009 Share Posted February 21, 2009 Aha *runs to change all my websites validators* haha Oops my bad, Its such a small percentage of users that have it turned off though Link to comment https://forums.phpfreaks.com/topic/146230-displaying-an-error-dialog-box/#findComment-767746 Share on other sites More sharing options...
phemi Posted February 22, 2009 Author Share Posted February 22, 2009 Thanks for your quick reply. i follow your instructionand get back to you. thanks Link to comment https://forums.phpfreaks.com/topic/146230-displaying-an-error-dialog-box/#findComment-768698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.