Validate User Password won't work

Validate User Password won't work

HELP!!!! I'm trying to show a popup modal box with a password field inside so that the users will type their password, if the password is invalid the page won't refresh and will show an alert that the password is invalid, if its correct it proceed for inserting in database


 here's screenshot



































here's my code

  1.                              <div class="modal fade" id="confirm-submit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  2.                                   <div class="modal-dialog">
  3.                                       <div class="modal-content">
  4.                                           <div class="modal-header">
  5.                                               Confirm your transaction
  6.                                           </div>
  7.                                           <div class="modal-body">
  8.                                               Are you sure you want to submit the following details?
  9.                                               <table class="table">
  10.                                                   <tr>
  11.                                                       <th>Input your Password:</th>
  12.                                                       <td><input type="password" name="type_pass"></td>
  13.                                                   </tr>
  14.                                               </table>
  15.                                           </div>
  16.                                           <div class="modal-footer">
  17.                                           <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
  18.                                           <a href="#" id="submit" class="btn btn-primary">Submit</a>
  19.                                       </div>
  20.                                   </div>
  21.                               </div>
  22.                             </div> 
  23. <script type="text/javascript">
  24.  
  25. var pass = $('#real_password');
  26. var repass = $('#type_pass');
  27. if(pass != repass){
  28.     alert('Invalid Password);
  29. } else {
  30.       $('#submit').click(function(){
  31.     alert('Form was submitting. Press OK button to continue.');
  32.     $('#MyForm').submit();
  33. }); 
  34. }
  35. </script>

Any ideas?