Buenas amigos, es mi primer post en el foro.
Tengo un problema con mi formulario. Necesito que luego de enviar la informacion a un correo se resete los campos del formulario.
Lo que tengo es lo siguiente:
Codigo HTML
<div class="layout-50 clear-fix overflow-fix">
<div class="layout-50-left">
<h3>En Mapa</h3>
<div id="map"></div>
<br/>
<h3>TwoPixels</h3>
<p>
Altos de las Acacias<br/>
Juan díaz, Panamá
</p>
<ul class="no-list contact-list">
<li class="contact-list-phone"><span>Phone:</span> +507 6945-4329</li>
<li class="contact-list-mail"><span>Mail:</span> [email protected]</li>
</ul>
</div>
<div class="layout-50-right">
<h3>Contáctenos</h3>
<form name="contact" id="contact" action="" method="post">
<div>
<div class="form-line block">
<input name="contact-user-name" type="text" id="contact-user-name" onfocus="if (this.value == 'Tu Nombre:') this.value = '';" value="Tu Nombre:"/>
</div>
<div class="form-line block">
<input type="text" name="contact-user-email" id="contact-user-email" value="Tu e-mail:" onfocus="if (this.value == 'Tu e-mail:') this.value = '';"/>
</div>
<div class="form-line block">
<textarea name="contact-message" cols="0" rows="0" id="contact-message" onfocus="if (this.value == 'Mensaje:') this.value = '';" textarea="textarea">Mensaje:</textarea>
</div>
<div class="form-line">
<a href="javascript:submitContactForm();" class="button block" id="contact-send">Send</a>
</div>
</div>
</form>
</div>
</div>
Codigo PHP
<?php
$contact_name = $_POST['contact-user-name'];
$contact_email = $_POST['contact-user-email'];
$contact_message = $_POST['contact-message'];
if($contact_name == true ){
$sender = $contact_email;
$receiver = "[email protected]";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: $contact_name \nEmail: $sender \nMessage: $contact_message \nIP: $client_ip";
$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
if( mail( $receiver, "Contacto Web Two Pixels $subject", $email_body, $extra )){
echo "succes-yes";
}else{
echo "success=no";
}
}
?>
Codigo Javascript
function submitContactForm()
{
blockForm('contact','block');
$.post('plugin/contact-form/contact-form.php',$('#contact').serialize(),submitContactF ormResponse,'json');
alert("Su mail ha sido enviado, muchas gracias!");
function limpiar() {
setTimeout('document.blockForm.reset()',2000);
return false;
}
}
/************************************************** ***************/
function submitContactFormResponse(response)
{
blockForm('contact','unblock');
$('#contact-user-name,#contact-user-email,#contact-message,#contact-send').qtip('destroy');
var tPosition=
{
'contact-send':{'my':'right center','at':'left center'},
'contact-message':{'my':'right center','at':'left center'},
'contact-user-name':{'my':'right center','at':'left center'},
'contact-user-email':{'my':'right center','at':'left center'}
};
if(typeof(response.info)!='undefined')
{
if(response.info.length)
{
for(var key in response.info)
{
var id=response.info[key].fieldId;
$('#'+response.info[key].fieldId).qtip(
{
style: { classes:(response.error==1 ? 'ui-tooltip-error' : 'ui-tooltip-success')},
content: { text:response.info[key].message },
position: { my:tPosition[id]['my'],at:tPosition[id]['at'] }
}).qtip('show');
}
}
}
}
Les agradezco la ayuda.
Saludos