양식을 제출하기 전에 프롬프트를 표시하기 위해이 코드를 작성했습니다. 양식 입력 값이 100보다 크면 사용자에게 대략 처리하는 데 걸리는 시간을 알리는 대화 상자가 표시됩니다. "확인"을 클릭하면 true를 반환하고 양식을 제출해야합니다. 취소를 클릭하면 false를 반환하고 양식을 제출하지 않아야합니다.jQuery JavaScript가 true/false를 제대로 반환하지 않음
양식이이 응답을 기다리지 않고 어쨌든 제출하는 것이 문제입니다. 나는
다음은 코드의 ... 무엇이 잘못되었는지 알아낼 수 없습니다 : 실행을 중지하고 닫을 때까지 기다리지 않고 대화를 표시$(document).ready(function() {
$("form#generate_vouchers").submit(function(){
if($("input#quantity").val() > 100){
var warning = "It will take around " + Math.round(($("input#quantity").val()/23)) + " seconds to generate this batch.<br />Generation will continue even if you leave this page.";
//Does around 23 codes per second, nearly all of that time is inserts.
$('<div title="Batch information"></div>').html(warning).dialog({
draggable: false,
modal: true,
minWidth: 350,
buttons: {
"Cancel" : function() {
$(this).dialog("close");
return false;
},
"Yes": function() {
$("input#submit").hide(300, function(){
$("img#loader").show(300);
});
return true;
}
}
});
}
else{
$("input#submit").hide(300, function(){
$("img#loader").show(300);
});
}
});
});
사용'e.preventDefault()'와'FALSE '조합을 반환 ... – Val