我有一个联系表格,它在 javascript 中进行了验证。我想在提交消息后清除表单。
我用
$(':input', '#contact')
.removeAttr('checked')
.removeAttr('selected')
.not(':button, :submit, :reset, :hidden, :radio, :checkbox')
.val('');
之后表单是干净的,但会触发 HTML5 验证,因此我将输入以红色突出显示。怎么去除红色,求大神帮忙。
(后来补充)不知道怎么办,我有他的代码:
$.ajax({
type: 'POST',
url: '/wordpress/wp-content/themes/conexion/config.php',
data: $("#contact").serialize()+"&filename="+response.filename+"&filepath="+response.filepath,
enctype: 'multipart/form-data',
success: function(data) {
if(data == "true") {
$("#message").replaceWith('<div id="message"><p>El mensaje</p><p>ha sido enviado</p></div>'); $(':input', '#contact')
.removeAttr('checked')
.removeAttr('selected')
.not(':button, :submit, :reset, :hidden, :radio, :checkbox')
.val('');
}
}
});
return false;