0

私はフォームの 7 つのステップを持っており、使用してsmart-wizardいます。「次へ」ボタンをクリックすると、各ステップでデータを保存して検証を行っていますが、ステップ 1 でエラーが発生している間にステップ 2 に移動しています。画面はステップ 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