Guest User

Untitled

a guest
Jul 17th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. $("#add_entry_dialog").dialog({
  2.  
  3. width: 460,
  4. draggable: true,
  5. modal: true,
  6. bgiframe: true, //for ie bugS
  7. autoOpen: false,
  8. resizable: false,
  9.  
  10. buttons: {
  11. 'Ok': function() {
  12. var datas = [];
  13.  
  14. //prepare the data for ajaxing to modelview.php
  15. $(':input', this).each(function() {
  16. datas.push(this.name + '=' + escape(this.value));
  17. })
  18.  
  19. $.ajax({
  20. type: "POST",
  21. url: "modelview.php",
  22. data: "action=add&" + datas.join('&'),
  23. beforeSend: function() {
  24. $("#box_ajax_gui > .ajax_gui").hide();
  25. },
  26. error: function() {
  27. alert("An error occured");
  28. },
  29. success: function() {
  30. fetch();
  31. }
  32. });
  33.  
  34. //CLEAR THE FORM - need work (i don't want to use jquery.form)
  35. //validator.resetForm();
  36.  
  37. $(':input', this).each(function() {
  38. this.value = '';
  39. })
  40. $(':select', this).each(function() {
  41. this.selectedIndex = 0;
  42. })
  43. if(validator) {
  44. alert('ok');
  45. } else {
  46. alert('nope');
  47. }
  48. alert(wow);
  49. $(this).dialog('close');
  50. },
  51.  
  52. Cancel: function() {
  53. $(this).dialog('close');
  54. }
  55. }
  56. });
  57.  
  58.  
  59. var validator = $("#add_form").validate({
  60. rules: {
  61. user_username: {
  62. required: true,
  63. minlength: 4,
  64. //remote: "customphpcheck.php"
  65. },
  66. user_password: {
  67. required: true,
  68. minlength: 5,
  69. },
  70. user_email: {
  71. required: true,
  72. email: true,
  73. //remote: "customphpcheck.php"
  74. }
  75. },
  76. messages: {
  77. user_username: {
  78. required: "Enter a User Name",
  79. minlength: jQuery.format("Enter at least {0} characters"),
  80. },
  81. user_password: {
  82. required: "Enter a password",
  83. minlength: jQuery.format("Enter at least {0} characters")
  84. },
  85. user_email: {
  86. required: "Please Enter an Email Address",
  87. }
  88. },
  89.  
  90. errorLabelContainer: $("ul", "#add_form .error"),
  91. wrapper: 'li',
  92. });
Add Comment
Please, Sign In to add comment