联系表 7:仅重置某些字段?
Contact Form 7: Reset only certain fields?
我正在使用 Wordpress (5.2.2) 和 Contact Form 7。如何在提交时仅重置某些字段?
成功提交后的默认操作是清除所有表单字段。我在 public_html/wp-content/plugins/contact-form-7/includes/js/scripts.js 中找到了似乎是重置的调用,并注释掉了指示的三行,
if ( 'mail_sent' == data.status ) {
// $form.each( function() {
// this.reset();
// } );
wpcf7.toggleSubmit( $form );
}
现在似乎可以防止在用户单击 "send" 时重置所有字段。但是,我有几个需要重置的下拉 selection 字段 ( [select id "opt1" "opt2" ... ] )。我有办法做到这一点吗?
if ( 'mail_sent' == data.status ) {
$form.each( function() {
$.each( $(this)[0], function() {
if (!($(this).hasClass("noResetOnMailSent"))){
$(this).not(':button, :submit, :reset, :hidden').val('').prop('checked', false).prop('selected', false);
}
} );
} );
这个问题已经在WordPress官方网站上解决了。在这里查看
https://wordpress.org/support/topic/how-to-not-clear-or-autofill-certain-fields-after-submission/
我正在使用 Wordpress (5.2.2) 和 Contact Form 7。如何在提交时仅重置某些字段?
成功提交后的默认操作是清除所有表单字段。我在 public_html/wp-content/plugins/contact-form-7/includes/js/scripts.js 中找到了似乎是重置的调用,并注释掉了指示的三行,
if ( 'mail_sent' == data.status ) {
// $form.each( function() {
// this.reset();
// } );
wpcf7.toggleSubmit( $form );
}
现在似乎可以防止在用户单击 "send" 时重置所有字段。但是,我有几个需要重置的下拉 selection 字段 ( [select id "opt1" "opt2" ... ] )。我有办法做到这一点吗?
if ( 'mail_sent' == data.status ) {
$form.each( function() {
$.each( $(this)[0], function() {
if (!($(this).hasClass("noResetOnMailSent"))){
$(this).not(':button, :submit, :reset, :hidden').val('').prop('checked', false).prop('selected', false);
}
} );
} );
这个问题已经在WordPress官方网站上解决了。在这里查看
https://wordpress.org/support/topic/how-to-not-clear-or-autofill-certain-fields-after-submission/