gpt4 book ai didi

jQuery - 智能向导。如何覆盖 "Previous"按钮验证?

转载 作者:行者123 更新时间:2023-12-01 07:29:28 26 4
gpt4 key购买 nike

基本上,我需要在单击“下一步”按钮时验证数据,但如果用户想返回,我不想验证他们是否引入了当前步骤的必填字段

    $('#wizard').smartWizard({ onLeaveStep: leaveAStepCallback,
onFinish: onFinishCallback
});

function leaveAStepCallback(obj) {
var step_num = obj.attr('rel'); // get the current step number
return validateSteps(step_num); // return false to stay on step and true to continue navigation
}

function onFinishCallback() {
if (validateAllSteps()) {
$('form').submit();
}
}

// Your Step validation logic
function validateSteps(stepnumber) {
var isStepValid = true;

if (stepnumber == 1) {
var e = document.getElementById("ContentPlaceHolder1_DropDownCustomers");
var strCustomer = e.options[e.selectedIndex].value;
if (strCustomer == "-1") {
//alert("Please select a Customer.");
$('#wizard').smartWizard('showMessage', 'Please select a Customer.');
isStepValid = false;
return isStepValid;
}
else {
var d = document.getElementById("ContentPlaceHolder1_DropDownTemplates");
var strTemplate = d.options[d.selectedIndex].value;
if (strTemplate == "-1") {
alert("Please select a Template.");
isStepValid = false;
return isStepValid;
}
else {
return isStepValid;
}
return isStepValid;
}
}

if (stepnumber == 2) {

if (document.getElementById("ContentPlaceHolder1_LabelMainDestData") != null) {
isStepValid = true;
}
else {
alert("Please introduce the Main Destination.");
isStepValid = false;
}


return isStepValid;

}

if (stepnumber == 3) {
isStepValid = true;
return isStepValid;
}

}

最佳答案

在 showStep 函数中只需编辑

if(stepIdx != curStepIdx)

if(stepIdx > curStepIdx)

它将解决您的问题

关于jQuery - 智能向导。如何覆盖 "Previous"按钮验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7316922/

26 4 0
文章推荐: java - double 移动小数点
文章推荐: Jquery加载脚本两次问题
文章推荐: jQuery slider 的 handle 不滑动
文章推荐: jQuery 对
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com