If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

trying to make this email form show sent ok in alert box, not on html page

Hello Guys,I have a simple contact form that relies on a php file to parse the message. if a visitor tries to skip a field, an alert box pops open saying to make the corrections. That works fine.

When the fields are filled in correctly, I would like the alert box to also be the way to notify them that the email is sent successfully instead of the current way... which shows a line of txt from the php file on a white page.

I'm a little bit confused on how to change this. If the fields are ok, id like the alert box to say delivered and reset the fields.

The only solution I can see to what you want is AJAX. Before looking at the code I want to make some comments as to why I did some things and why I took some things out.
In your forms you use keyup to call limitarelungime function in the phone and message input, but have not included it. All this function does is limit the number of key stokes that can be used in that input box. I left it in, but if your not going to use it, take it out.
I removed the form and the reset button. I also changed the submit button. If these are important to you put them back, except for the submit.
I gave the elements of the old form ID's equal to the names. I re-wrote the function that checks for empty boxes. I removed the everif function, if you want to use it put it back and call it from the section that checks phone for empty box.

After function tommytwotone checks for empty it does an if to see if everything has input and then starts the ajax magic. This is not my code but comes from tizag. Two things of interest here. I use:

Code:

alert(ajaxRequest.responseText);

to display the returned php echo. This satisfies your requirement. But you may want to use

Really never belonged here.
Please take note of the echo at the end. That's what will appear in the alert on the HTML page.
I commented out the mail line so I can run this on my server. Put it back in.