以下のボタンがあります。
<p><button id='submitstudents'>Submit Students</button></p>
ボタンに実行させたいのは、editvalidation()
関数をトリガーすることです。それが渡された場合は、確認に進みます。検証用に jquery コードを設定し、検証に合格した場合に確認を表示するように設定しましたが、ボタンをeditvalidation()
クリックして whenc を返すにはどうすればよいですか?
以下は、関連する jquery コードです。
編集検証():
function editvalidation()
{
if ($("#coursesDrop").val()==""){
$("#courseAlert").html("Please Select a Course from the Course Drop Down Menu");
}
if ($("#coursesDrop").val()!="" && $("#courseadd").children().length==0){
$("#courseAlert").html("You have not Selected any Students you wish to Add into Course");
}
if ($("#coursesDrop").val()!="" && $("#courseadd").children().length!=0){
return true;
}
return false;
}
showConfirm():
function showConfirm(){
var courseNoInput = document.getElementById('currentCourse').value;
var courseNameInput = document.getElementById('currentCourseName').value;
if (editvalidation()) {
var confirmMsg=confirm("Are you sure you want to add your selected Students to this Course:" + "\n" + "Course: " + courseNoInput + " - " + courseNameInput);
if (confirmMsg==true)
{
submitform();
}
}
}
ボタンのクリックをチェックする現在のさえ:
$('body').on('click', '#submitstudents', showConfirm);