Jump to content

displaying an error dialog box


phemi

Recommended Posts

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

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 :)

   

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.