クリックしても何も起こらない送信ボタンに苦労しています。問題はeditvalidation()トリガーされていないと思いますが、よくわかりません。この場合、どのようにトリガーできますか? 送信ボタンの上に検証を表示したいです。私の質問は、送信ボタンに何かをさせる方法です。
エラーはありません:
コード:
<script type="text/javascript">
            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;
    }
            </script>
    <div id='lt-container'>
    <form action='addstudentcourse.php' method='post' id='courseForm'>
    <p id='warnings'></p>
    <p><strong>Courses:</strong> <select name="course" id="coursesDrop">
    <option value="">Please Select</option>
    <option value='19'>BIO234 - Biology</option>
    <option value='1'>INFO101 - Bsc Information Communication Technology</option>
    <option value='2'>INFO102 - Bsc Computing</option>
    </select> </p>   
    </form>
    <form id='updateForm'>
        <p><strong>Course Chosen:</strong></p>
        <table>
        <tr>
        <th></th>
        <td><input type='hidden' id='currentCourseId' name='CourseIdcurrent' value='' /> </td>
        </tr>
        <tr>
        <th>Course ID:</th>
        <td><input type='text' id='currentCourse' name='Coursecurrent' readonly='readonly' value='' /> </td>
        </tr>
        <tr>
        <th>Course Name:</th>
        <td><input type='text' id='currentCourseName' name='CourseNamecurrent' readonly='readonly' value='' /> </td>
        </tr>
        <tr>
        <th>Duration (Years):</th>
        <td><input type='text' id='currentDuration' name='Durationcurrent' readonly='readonly' value=''/> </td>
        </tr>
        </table>
        </form>
    <form id='studentExistForm'>
    <p><strong>Current Students in Chosen Course:</strong></p>
    <p><select name="studenttextarea" id="studentselect" size="10"></select></p>
    </form> 
    </div>
    <div id='rt-container'>
    <form id='studentRemainForm'>
    <p><strong>Available Students to Enrol:</strong></p>
    <p><select multiple="multiple" name="remaintextarea" id="studentremain" size="10"></select></p>
    <table id='addtbl'>
    <tr>
    </table>
    </form>
    <form id='studentAddForm'>
    <p><strong>Students to Add to Course:</strong></p>
    <p><select multiple="multiple" name="addtextarea" id="studentadd" size="10"></select></p>
    <table id='removetbl'>
    <tr>
    </table>
    <div id='studentAlert'></div>
    </form>
    <p><button id='submitstudents'>Submit Students</button></p>
    </div>
        <script type="text/javascript">    
                 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);     
        </script>