Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.25 KB | None | 0 0
  1.  
  2. @{
  3. Layout = null;
  4. }
  5.  
  6. <!DOCTYPE html>
  7.  
  8. <html>
  9. <head>
  10. <meta name="viewport" content="width=device-width" />
  11. <title>Index</title>
  12. <link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
  13. <link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
  14. <link href="~/Datepicker/jquery-ui.min.css" rel="stylesheet" />
  15. <script src="~/Scripts/modernizr-2.6.2.js"></script>
  16. <script src="~/Scripts/jquery-3.4.1.min.js"></script>
  17. <script src="~/Scripts/bootstrap.js"></script>
  18. <style type="text/css">
  19. .box {
  20. width: 33%;
  21. height: 200px;
  22. background: white;
  23. }
  24.  
  25. .font-style {
  26. background-color: #000080;
  27. color: white;
  28. border-top-left-radius: 3%;
  29. border-top-right-radius: 3%;
  30. padding: 15px;
  31. }
  32.  
  33. .cntr-hdr {
  34. display: flex;
  35. align-items: center;
  36. align-content: center;
  37. justify-content: space-between; /*button exit na jadi gak nempel lagi ke modal title*/
  38. }
  39.  
  40. .background-lgn {
  41. position: absolute;
  42. margin: auto;
  43. left: 0;
  44. top: 0;
  45. bottom: 0;
  46. right: 0;
  47. width: 100%;
  48. height: 100%;
  49. background-color: #f0f5f5;
  50. border-style: solid;
  51. border-width: 1px;
  52. text-align: center;
  53. }
  54.  
  55. .cntr-content {
  56. position: absolute;
  57. margin: auto;
  58. left: 30%;
  59. top: 35%;
  60. text-align: center;
  61. }
  62.  
  63. .form-geser {
  64. padding-left: 5%;
  65. padding-right: 5%;
  66. }
  67.  
  68. .brdr-lgn {
  69. border-color: #000080;
  70. border-style: solid;
  71. border-width: 2px;
  72. border-radius: 3%;
  73. }
  74.  
  75. .fnt {
  76. font-weight: bold;
  77. color: #000080;
  78. }
  79.  
  80. .batas-bawah {
  81. margin-bottom: 0px;
  82. }
  83.  
  84. .background-layout {
  85. background-color: #f0f5f5;
  86. }
  87. </style>
  88. <style type="text/css">
  89. [data-validation-message] {
  90. display: none;
  91. color: red;
  92. font-weight: bold;
  93. }
  94.  
  95. [data-validation-message].message-visible {
  96. display: block;
  97. }
  98.  
  99. .blueborder {
  100. border-color: blue;
  101. }
  102.  
  103. .blueborder.invalid {
  104. border-color: red;
  105. }
  106. </style>
  107. </head>
  108. <body class="background-layout">
  109. <form class="form-inline form-geser" id="idFrmForgotPasswordForm">
  110. <table class="box cntr-content brdr-lgn" role="dialog" aria-labelledby="dialogTitle" aria-describedby="dialog1Desc">
  111. <tr id="dialog1Desc">
  112. <td>
  113. <p class="font-style batas-bawah" id="dialogTitle" align="left">Form Lupa Password</p>
  114. </td>
  115. </tr>
  116. <tr>
  117. <td>
  118. <input type="hidden" name="id" id="idget" />
  119. <input type="password" name="abpwd" class="form-control" data-validate="required" id="idInpNewPassword" placeholder="New Password">
  120. <small role="alert" aria-hidden="true" data-validation-message="required">Password harus diisi.</small>
  121. </td>
  122. </tr>
  123. <tr>
  124. <td>
  125. <input type="password" class="form-control" data-validate="required password" id="idInpRetypeNewPassword" placeholder="Re-Type New Password">
  126. <small role="alert" aria-hidden="true" data-validation-message="required">Password harus diisi.</small>
  127. <small role="alert" aria-hidden="true" data-validation-message="password">Password tidak sama, pastikan anda memasukkan password yang sama.</small>
  128. </td>
  129. </tr>
  130. <tr>
  131. <td>
  132. <button type="submit" class="btn" id="idBtnForgotPasswordForm" style="background-color: #000080; color: white;">&nbsp Submit &nbsp</button>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>
  137. <p class="fnt" style=""> 2020 - Xsis Mitra Utama</p>
  138. </td>
  139. </tr>
  140. </table>
  141. </form>
  142. <script src="~/Scripts/jquery-1.10.2.min.js"></script>
  143. <script src="~/Scripts/bootstrap.min.js"></script>
  144. <script src="~/Scripts/jquery-3.4.1.min.js"></script>
  145. </body>
  146. </html>
  147.  
  148. <script>
  149. $(document).ready(function () {
  150.  
  151. $.ajax({
  152. url: '/ForgotPasswordForm/Tampil',
  153. method: 'Get',
  154. success: function (mdl) {
  155. debugger;
  156. },
  157. error: function (mdl) {
  158. debugger;
  159. }
  160. });
  161.  
  162. var idcoba = parseInt(1);
  163. debugger;
  164. $.ajax({
  165. url: '/ForgotPasswordForm/AmbilData',
  166. data: { ID : idcoba },
  167. method: 'Post',
  168. success: function (fpf) {
  169. debugger;
  170. $('#idget').val(fpf.id);
  171. },
  172. error: function (fpf) {
  173. debugger;
  174. }
  175. });
  176. debugger;
  177.  
  178. });
  179.  
  180. //$('#idBtnForgotPasswordForm').click(function () {
  181. function editforgotpasswordform() {
  182. debugger;
  183. var vDataBarang = $('#idFrmForgotPasswordForm').serialize();
  184. $.ajax({
  185. url: '/ForgotPasswordForm/EditSimpan',
  186. data: vDataBarang,
  187. method: 'Post',
  188. success: function (mdl) {
  189. if (mdl.EditSimpan == "Berhasil") {
  190. debugger;
  191. alert("Password berhasil diganti");
  192. //
  193. //
  194. //$('#idMdlEditOrganisasi').close;
  195.  
  196. location.reload();
  197. }
  198. else {
  199. debugger;
  200. alert("Password gagal diganti");
  201. }
  202. },
  203. error: function (mdl) {
  204. debugger;
  205. }
  206. });
  207. }
  208. </script>
  209.  
  210. <script>
  211. // (1) Defining our validator-functions
  212. // for later use. They return
  213. // "true", if the validation passes.
  214. const validators = {
  215. // Checks the field for emptiness.
  216. required: element => element.value.length > 0,
  217. password: element=>element.value == document.getElementById("idInpNewPassword").value,
  218. // Checks if there are no numbers
  219. // in the field.
  220. noNumbers: element => !element.value.match(/[0-9]/g),
  221. // Checks if the value is shorter
  222. // than 10 characters.
  223. maxLength: element => element.value.length <= 10,
  224. // Checks if the checkbox is checked.
  225. mustBeChecked: element => element.checked
  226. };
  227. // (2) Check the contents of an input,
  228. // get all validators, and mark
  229. // the field in case of invalidity.
  230. function validateElement(element) {
  231. resetValidation(element);
  232. // Store all validators from the
  233. // data-validate-attribute into
  234. // an array.
  235. const rules = element.dataset.validate.split(" ");
  236. // For every validator on the
  237. // field...
  238. rules.forEach(rule => {
  239. // ...find the corresponding
  240. // validator-function from our
  241. // object from #1 and call it
  242. // with the element as parameter.
  243. if (validators[rule](element)) {
  244. // If the function returns true, all is fine.
  245. debugger;
  246. return;
  247. } else {
  248. // If it returns false, the
  249. // validation failed.
  250. // In that case, the
  251. // markElementInvalid-function
  252. // takes care of showing the
  253. // error-message.
  254. markElementInvalid(element, rule);
  255. }
  256. });
  257. }
  258. // (3) Adds classes to an element,
  259. // so it appears invalid. Also
  260. // it picks the correct feedback-
  261. // message and sets it visible.
  262. function markElementInvalid(element, validatorName) {
  263. element.classList.add("invalid");
  264. element.setAttribute("aria-invalid", true);
  265. const feedbackMessage = element.parentNode.querySelector(
  266. `[data-validation-message=${validatorName}]`
  267. );
  268. feedbackMessage.classList.add("message-visible");
  269. feedbackMessage.setAttribute("aria-hidden", false);
  270. }
  271. // (4) Removes all traces of
  272. // validation from an element,
  273. // like the error-messages and
  274. // the styling.
  275. // (Pretty much the opposite of #3)
  276. function resetValidation(element) {
  277. element.classList.remove("invalid");
  278. element.setAttribute("aria-invalid", false);
  279. element.parentNode
  280. .querySelectorAll("[data-validation-message]")
  281. .forEach(e => {
  282. e.classList.remove("message-visible");
  283. e.setAttribute("aria-hidden", true);
  284. });
  285. }
  286. // (5) Store the form and its
  287. // inputs in variables.
  288. const form = document.getElementById("idFrmForgotPasswordForm");
  289. const formElements = Array.from(form.elements);
  290. // (6) Every input gets an
  291. // event-listener attached.
  292. formElements.forEach(formElement => {
  293. // Do nothing if the element has
  294. // no data-validate-attribute.
  295. if (!formElement.dataset) return;
  296. if (!formElement.dataset.validate) return;
  297. // Attach the blur-event-listener
  298. // to the element.
  299. formElement.addEventListener("", () => {
  300. // This means, validateElement will
  301. // be called everytime the element
  302. // loses focus.
  303. validateElement(formElement);
  304. });
  305. });
  306. // (7) We're doing what we did at #3,
  307. // only on form-submit, and for
  308. // every field.
  309. form.addEventListener("submit", event => {
  310. // Let's assume, everything is fine.
  311. let formIsValid = true;
  312. form.classList.remove("invalid");
  313. // We'll check every field in the form.
  314. // (same as #3)
  315. formElements.forEach(formElement => {
  316. if (!formElement.dataset) return;
  317. if (!formElement.dataset.validate) return;
  318. validateElement(formElement);
  319. });
  320. // If there are any "invalid"-classes
  321. // after we checked all fields, the form
  322. // is invalid...
  323. formIsValid = form.querySelectorAll(".invalid").length === 0;
  324. // ...and will not be submitted.
  325. if (formIsValid === false) {
  326. form.classList.add("invalid");
  327. event.preventDefault();
  328. } else {
  329. debugger;
  330. editforgotpasswordform();
  331. }
  332. });
  333. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement