尽管用户似乎有问题,但我试图在用户单击MailChimp提交后清除输入字段。
我已经尝试了很多选项来使其正常工作,但是没有任何窍门。你能帮我吗?
谢谢。
HTML
<div class="mc-field-group">
<div class="row">
<div class="col-sm-6 col-md-6">
<input type="text" placeholder="Type your name here..."
value=""
name="NOME" class="form-control input-box required pull-
right" id="mce-NOME">
</div>
<div class="col-sm-6 col-md-6">
<input type="text" placeholder="Type your email here..."
value="" name="EMAIL" class="form-control input-box
required pull-left" id="mce-EMAIL">
</div>
</div>
</div>
<div class="mc-field-group">
<div class="row">
<div class="col-sm-12">
<textarea limit="1000" placeholder="Type your message here..."
style="height: 100px; width: 500px;" value=""
name="MENSAGEM" class="form-control textarea-box required"
id="mce-MENSAGEM">
</textarea>
</div>
</div>
</div>
JS
$('#mc-embedded-subscribe-form').ajaxChimp({
callback: mailchimpCallback,
url: ""
});
function mailchimpCallback(resp) {
if (resp.result === 'success') {
$('.subscription-success').html('<span class="icon_check_alt2"></span>' + ' Agradecemos por sua mensagem.<br />Entraremos em contato em breve.').fadeIn(1000);
$('.subscription-error').fadeOut(500);
} else if(resp.result === 'error') {
$('.subscription-error').html('<span class="icon_close_alt2"></span>' + 'Oops... Houve um erro ao tentar enviar sua mensagem.<br/>Por favor, tente novamente em alguns minutos.').fadeIn(1000);
}
}
答案 0 :(得分:0)
您可以简单地将其放入成功处理程序中,例如
$('.mc-field-group input, .mc-field-group textarea').val('')
应该可以解决问题。
如果表单中包含字段,则可以在表单上使用reset
$('#formId')[0].reset();
答案 1 :(得分:0)
$('.mc-field-group').find('input,textarea').val('')
答案 2 :(得分:0)
您可以使用$(':input').val('');
和$('textarea').val('');
$("#reset").click(function(){
$(':input').val('');
$('textarea').val('');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="mc-field-group">
<div class="row">
<div class="col-sm-6 col-md-6">
<input type="text" placeholder="Type your name here..."
value=""
name="NOME" class="form-control input-box required pull-
right" id="mce-NOME">
</div>
<div class="col-sm-6 col-md-6">
<input type="text" placeholder="Type your email here..."
value="" name="EMAIL" class="form-control input-box
required pull-left" id="mce-EMAIL">
</div>
</div>
</div>
<div class="mc-field-group">
<div class="row">
<div class="col-sm-12">
<textarea limit="1000" placeholder="Type your message here..."
style="height: 100px; width: 500px;" value=""
name="MENSAGEM" class="form-control textarea-box required"
id="mce-MENSAGEM">
</textarea>
</div>
</div>
</div>
<input type="button" id="reset" value="Reset">