Guest User

Untitled

a guest
Jul 5th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. <input id="saveButton" type="submit" value="Save" />
  2. <input id="cancelButton" type="button" value="Cancel" />
  3. <script src="../../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
  4. <script type="text/javascript">
  5.  
  6. $(document).ready(function () {
  7. $("form").submit(function (e) {
  8. $.ajax({
  9. url: '@Url.Action("HasJobInProgress", "ClientChoices")/',
  10. data: { id: '@Model.ClientId' },
  11. success: function (data) {
  12. showMsg(data, e);
  13. },
  14. cache: false
  15. });
  16. });
  17. });
  18. $("#cancelButton").click(function () {
  19. window.location = '@Url.Action("list", "default", new { clientId = Model.ClientId })';
  20. });
  21. $("[type=text]").focus(function () {
  22. $(this).select();
  23. });
  24. function showMsg(hasCurrentJob, sender) {
  25. if (hasCurrentJob == "True") {
  26. alert("The current clients has a job in progress. No changes can be saved until current job completes");
  27. if (sender != null) {
  28. sender.preventDefault();
  29. }
  30. return false;
  31. }
  32. }
  33.  
  34. </script>
  35.  
  36. $("form").submit(function (e) {
  37. e.preventDefault(); // this will prevent from submitting the form.
  38. ...
  39.  
  40. $(document).ready(function () {
  41. $("form").submit(function (e) {
  42. e.preventDefault(); //prevent default form submit
  43. $.ajax({
  44. url: '@Url.Action("HasJobInProgress", "ClientChoices")/',
  45. data: { id: '@Model.ClientId' },
  46. success: function (data) {
  47. showMsg(data);
  48. },
  49. cache: false
  50. });
  51. });
  52. });
  53. $("#cancelButton").click(function () {
  54. window.location = '@Url.Action("list", "default", new { clientId = Model.ClientId })';
  55. });
  56. $("[type=text]").focus(function () {
  57. $(this).select();
  58. });
  59. function showMsg(hasCurrentJob) {
  60. if (hasCurrentJob == "True") {
  61. alert("The current clients has a job in progress. No changes can be saved until current job completes");
  62. return false;
  63. } else {
  64. $("form").unbind('submit').submit();
  65. }
  66. }
  67.  
  68. if(e.preventDefault)
  69. e.preventDefault();
  70. else
  71. e.returnValue = false;
  72.  
  73. $(document).ready(function () {
  74. $("form").submit(function (e) {
  75. $.ajax({
  76. url: '@Url.Action("HasJobInProgress", "ClientChoices")/',
  77. data: { id: '@Model.ClientId' },
  78. success: function (data) {
  79. showMsg(data, e);
  80. },
  81. cache: false
  82. });
  83. e.preventDefault();
  84. });
  85. });
  86.  
  87. $(document).ready(function () {
  88. $("form").submit(function (e) {
  89. /* put your form field(s) you want to validate here, this checks if your input field of choice is blank */
  90. if(!$('#inputID').val()){
  91. e.preventDefault(); // This will prevent the form submission
  92. } else{
  93. // In the event all validations pass. THEN process AJAX request.
  94. $.ajax({
  95. url: '@Url.Action("HasJobInProgress", "ClientChoices")/',
  96. data: { id: '@Model.ClientId' },
  97. success: function (data) {
  98. showMsg(data, e);
  99. },
  100. cache: false
  101. });
  102. }
  103.  
  104.  
  105. });
  106. });
  107.  
  108. <script type="text/javascript">
  109. function CheckData() {
  110. //you may want to check something here and based on that wanna return true and false from the function.
  111. if(MyStuffIsokay)
  112. return true;//will cause form to postback to server.
  113. else
  114. return false;//will cause form Not to postback to server
  115. }
  116. </script>
  117. @using (Html.BeginForm("SaveEmployee", "Employees", FormMethod.Post, new { id = "EmployeeDetailsForm" }))
  118. {
  119. .........
  120. .........
  121. .........
  122. .........
  123. <input type="submit" value= "Save Employee" onclick="return CheckData();"/>
  124. }
  125.  
  126. $('form').submit(function (e) {
  127. if (radioButtonValue !== "0") {
  128. e.preventDefault();
  129. }
  130. });
Add Comment
Please, Sign In to add comment