0

我有 7 个步骤,并且正在使用smart-wizard. 单击“下一步”按钮后,我将在每个步骤中保存我的数据并进行验证,但它正在移动到第 2 步,同时在第 1 步给出错误。屏幕不会在第 1 步停止以完成所有操作并转到下一步。有人可以帮我吗?

我试过e.preventDefault()了,return false;但它并没有停止

function saveLaunchDetails() {
  var launchName = $("#launch_name").val().trim();
  var launchMonth = $("#startdate").val().trim();
  var launchNature = $("#launch_nature").val();
  var launchCat = $("#launch_category").val().trim();
  var launchBus = $("#launch_business").val().trim();
  var launchClass = $("#launch_classifiction").val();
  var cutspec = $('.multiselect').text();
  var formspe = $('#format_input').val();
  var townspe = $('#town_input').val();
  var othrspe = $('#launch_input').val();
  var geo = $('#editGeography').val();
  var launchNature2 = "";

  if ($('#launch_nature').val() == 'Customer Specific') {
    launchNature2 = cutspec;
  } else if ($('#launch_nature').val() == 'Format Specicfic') {
    launchNature2 = formspe;
  } else if ($('#launch_nature').val() == 'Regional') {
    launchNature2 = geo;
  } else if ($('#launch_nature').val() == 'Town Specific') {
    launchNature2 = townspe;
  } else if ($('#launch_nature').val() == 'Others') {
    launchNature2 = othrspe;
  }

  if (launchName == "" || launchName == null) {
    ezBSAlert({
      messageText: "Please enter launch name",
      alertType: "info"
    }).done(function(e) {
      //console.log('hello');
    });
    return false;
  } else if (launchMonth == "" || launchMonth == null) {
    ezBSAlert({
      messageText: "Please select launch month",
      alertType: "info"
    }).done(function(e) {
      //console.log('hello');
    });
    return false;
  } else if (launchNature == "") {
    ezBSAlert({
      messageText: "Please select launch nature",
      alertType: "info"
    }).done(function(e) {
      //console.log('hello');
    });
    return false;
  } else if (launchBus == "" || launchBus == null) {
    ezBSAlert({
      messageText: "Estimated Launch business case can not be blank",
      alertType: "info"
    }).done(function(e) {
      //console.log('hello');
    });
    return false;
  } else if (launchCat == "" || launchCat == null) {
    ezBSAlert({
      messageText: "Launch Category can not be blank",
      alertType: "info"
    }).done(function(e) {
      //console.log('hello');
    });
    return false;
  } else if (launchClass == "" || launchClass == null) {
    ezBSAlert({
      messageText: "Launch Classification can not be blank",
      alertType: "info"
    }).done(function(e) {
      //console.log('hello');
    });
    return false;
  } else {
    if (launchNature == "1") {
      launchNature2 = [""];
    } else if (launchNature == "6") {
      var launchInput = $("#launch_input").val().trim();
      if (launchInput == "" || launchBus == null) {
        ezBSAlert({
          messageText: "Launch Input can not be blank",
          alertType: "info"
        }).done(function(e) {
          //console.log('hello');
        });
        return false;
      }
    }

    $.ajax({
      url: 'saveLaunchDetails.htm',
      dataType: 'json',
      type: 'post',
      async: false,
      contentType: 'application/json',
      data: JSON.stringify({
        "launchName": launchName,
        "launchMonth": launchMonth,
        "launchNature": launchNature,
        "launchNature2": launchNature2,
        "launchBusinessCase": launchBus,
        "categorySize": launchCat,
        "classification": launchClass
      }),
      processData: false,
      success: function(data, textStatus, jQxhr) {
        $('#response pre').html(JSON.stringify(data));
      },
      error: function(jqXhr, textStatus, errorThrown) {
        console.log(errorThrown);
      }
    });
    return false;
  }
}
<input type="button" value="Next" class="btn btn-secondary sw-btn-next nxtclassification" onclick="saveLaunchDetails();" id="lnchdetail" style="float: right;" />

在此处输入图像描述

4

0 回答 0