我正在构建基于联系人表单7的自定义逐步表单,在进入下一节之前我需要验证字段。如何在单击时调用验证函数?我在文件里找不到。
$( "#next-section" ).click(function() {
//call validate function (how to do this)??
if('validate function no errors') {
//call my scripts
}
});发布于 2018-11-20 18:08:20
我也遇到了同样的问题,并找到了解决办法。
我有两个步骤表单,我想提交表单,然后检查第一步中的输入字段是否被验证(显然,表单无法发送,因为第二步的字段很少,这仅仅是为了使用CF7验证)。
$('.go_to_step_2').on('click', function () {
var input = $('input[name="your-name"]'),
form = $(this).parents('.wpcf7-form');
form.submit();
// trigger just one time! so validation works correctly in the 2nd step
form.parent().one('wpcf7:invalid', function() {
if( !input.hasClass('wpcf7-not-valid') ) {
// this will hide valid-tips from step 2
$('.step_2').find('.wpcf7-not-valid-tip').fadeOut(0);
// do stuff to show step 2
}
});
});https://stackoverflow.com/questions/36304816
复制相似问题